[IPython-user] Fwd: Preparing for the 0.7.4 release

DaveS davls@telus....
Fri Mar 23 09:14:41 CDT 2007


On Thu, Mar 22 2007, Fernando Perez wrote:

> [ This was meant for the list...]
>
> ---------- Forwarded message ----------
> From: Fernando Perez <fperez.net@gmail.com>
> Date: Mar 22, 2007 7:01 PM
> Subject: Re: [IPython-user] Preparing for the 0.7.4 release
> To: Stefan van der Walt <stefan@sun.ac.za>
>
>
> On 3/22/07, Stefan van der Walt <stefan@sun.ac.za> 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:
>> >
>> > http://projects.scipy.org/ipython/ipython/ticket/129
>> >
>> > 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.
>>
>> Cheers
>> Stéfan
>>
>> Index: IPython/iplib.py
>> ===================================================================
>> --- IPython/iplib.py    (revision 2164)
>> +++ IPython/iplib.py    (working copy)
>> @@ -1977,7 +1977,7 @@
>>          """
>>
>>          try:
>> -            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
>>
>
> Thanks!!!
>
> http://projects.scipy.org/ipython/ipython/changeset/2168
>
> 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.
>
> Cheers,
>
> f

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:

In [1]: 1
---------------------------------------------------------------------------
<type 'exceptions.TypeError'>             Traceback (most recent call last)

C:\Python25\lib\site-packages\IPython\iplib.py in raw_input(self=<IPython.iplib.InteractiveShell object at 0x00A85A90>, prompt='\n\x1b[0;34mIn [\x1b[1;34m1\x1b[0;34m]: \x1b[0m', continue_prompt=0)
   1978 
   1979 try:
-> 1980 line = raw_input_original(prompt).decode(sys.stdin.encoding)
        line = undefined
        global raw_input_original = <built-in function raw_input>
        prompt.decode = <built-in method decode of str object at 0x00DC88A0>
        global sys.stdin.encoding = None
   1981 except ValueError:
   1982 warn("\n********\nYou or a %run:ed script called sys.stdin.close() or sys.stdout.close()!\nExiting IPython!")

<type 'exceptions.TypeError'>: decode() argument 1 must be string, not None

In [2]: 


-- 
DS



More information about the IPython-user mailing list