[IPython-user] Fwd: Preparing for the 0.7.4 release
Fri Mar 23 14:13:39 CDT 2007
> On Thu, Mar 22 2007, Fernando Perez wrote:
>> [ This was meant for the list...]
>> ---------- Forwarded message ----------
>> From: Fernando Perez <firstname.lastname@example.org>
>> Date: Mar 22, 2007 7:01 PM
>> Subject: Re: [IPython-user] Preparing for the 0.7.4 release
>> To: Stefan van der Walt <email@example.com>
>> On 3/22/07, Stefan van der Walt <firstname.lastname@example.org> wrote:
>>> On Thu, Mar 22, 2007 at 05:28:56PM -0600, Fernando Perez wrote:
>>>> But there's one in particular that I'm a bit stumped on, the unicode bug:
>>>> If anyone knows what to do here, I'd be very grateful for help
>>>> (patches, ideas, a reference on what to do, whatever).
>>> Hi Fernando
>>> The attached patch fixes the problem. I didn't check to see whether
>>> it crops up anywhere else though, but I believe that is the right way
>>> to handle input from the terminal.
>>> Index: IPython/iplib.py
>>> --- IPython/iplib.py (revision 2164)
>>> +++ IPython/iplib.py (working copy)
>>> @@ -1977,7 +1977,7 @@
>>> - line = raw_input_original(prompt)
>>> + line = raw_input_original(prompt).decode(sys.stdin.encoding)
>>> except ValueError:
>>> warn("\n********\nYou or a %run:ed script called sys.stdin.close() or sys.stdout.close()!\nExiting IPython!")
>>> self.exit_now = True
>> It works in all the tests I did quickly. If anyone finds a condition
>> where this doesn't help, or knows a good reason why it might be the
>> wrong approach, please let me know or reopen the ticket.
>> Otherwise, lots of brownie points to Stefan for this one.
> Sorry, but I found a problem with this under emacs. (WinXP NTEmacs 21.3)
> In the cmd window, sys.stdin.encoding = 'cp850'. In emacs
> sys.stdin.encoding = None. This breaks ipython under emacs:
I have found more problems. Below is a transcript of a session in
regular python with a cp850 terminal and ipython in the same terminal.
As you can see there was a bug introduced recently that gives an
exception in the prefilter code if the line starts with a string
containing non-ascii characters, this worked a couple of days ago.
The new raw_input patch seems to translate åäö to some kind of two-byte
unicode when assigning to regular strings but it seems to work fine when
assigning to unicode strings. I have been playing with
eval('"åäö"'.decode("xxx")) (where xxx is a valid encoding) and
eval('u"åäö"'.decode("xxx")) but I have not been able to find anything
that works in both cases. I wonder if something other than eval is used
for the regular python prompt.
Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on
Type "help", "copyright", "credits" or "license" for more information.
Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.
IPython 0.7.4.svn.r2159 -- An enhanced Interactive Python.
? -> Introduction to IPython's features.
%magic -> Information about IPython's 'magic' % functions.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.
In : "åäö"
exceptions.UnicodeEncodeError Traceback (most
teractiveShell object>, line=u'"\xe5\xe4\xf6"', continue_prompt=0)
2243 out = 
2244 for l in line.rstrip('\n').split('\n'):
-> 2245 out.append(self._prefilter(l, continue_prompt))
out.append = <built-in method append of list object at 0x012FE490>
self._prefilter = <bound method InteractiveShell._prefilter of
iplib.InteractiveShell object at 0x00A22BB0>>
l = u'"\xe5\xe4\xf6"'
continue_prompt = 0
2246 return '\n'.join(out)
Shell object>, line=u'"\xe5\xe4\xf6"', continue_prompt=0)
2147 # Let's try to find if the input line is a magic fn
2148 oinfo = None
-> 2149 if hasattr(self,'magic_'+iFun):
global hasattr = undefined
self = <IPython.iplib.InteractiveShell object at 0x00A22BB0>
iFun = u'"\xe5\xe4\xf6"'
2150 # WARNING: _ofind uses getattr(), so it can consume generators and
2151 # cause other side effects.
UnicodeEncodeError: 'ascii' codec can't encode characters in position
al not in range(128)
In : a="åäö"
In : a
In : a=u"åäö"
In : a
More information about the IPython-user