[Ipython-tickets] [IPython] #201: IPython does not handle unicode at continuation prompt

IPython ipython-tickets@scipy....
Fri Nov 30 23:57:56 CST 2007


#201: IPython does not handle unicode at continuation prompt
---------------------+------------------------------------------------------
 Reporter:  jinks    |       Owner:  fperez
     Type:  defect   |      Status:  new   
 Priority:  normal   |   Milestone:        
Component:  ipython  |     Version:        
 Severity:  major    |    Keywords:        
---------------------+------------------------------------------------------
 This seems to be a problem with the Unix readline bindings.

 Some Unicode strings which are handled fine at the normal input prompt
 cause IPython to bail out inside a continuation prompt, i.e. while
 defining a function.

 Example:
 {{{
 In [6]: r = u'ö'

 In [7]: def mm():
    ...:     return r
    ...:

 In [8]: mm
 Out[8]: <function mm at 0x95d9b0>

 In [9]: mm()
 Out[9]: u'\xf6'

 In [10]: def gg():
    ....:     return u'ö'
 ---------------------------------------------------------------------------
 <type 'exceptions.UnicodeEncodeError'>    Traceback (most recent call
 last)

 /usr/lib64/python2.5/site-packages/IPython/iplib.py in raw_input(self,
 prompt, continue_prompt)
    2040                         newhist = self.input_hist_raw[-1].rstrip()
    2041
 self.readline.remove_history_item(histlen-1)
 -> 2042
 self.readline.replace_history_item(histlen-2,newhist)
    2043                     except AttributeError:
    2044                         pass # re{move,place}_history_item are new
 in 2.4.

 <type 'exceptions.UnicodeEncodeError'>: 'ascii' codec can't encode
 character u'\xf6' in position 23: ordinal not in range(128)
    ....:
 KeyboardInterrupt

 In [10]:
 }}}

 The error does not occur when readline is disabled.

 Also this does not occur in a normal python prompt (which also seems to
 use readline)
 See:
 {{{
 Python 2.5.1 (r251:54863, Nov 28 2007, 10:32:59)
 [GCC 4.2.2 (Gentoo 4.2.2 p1.0)] on linux2
 Type "help", "copyright", "credits" or "license" for more information.
 >>> def bla():
 ...     return u'ö'
 ...
 >>> bla
 <function bla at 0x2b2c25db9ed8>
 >>> bla()
 u'\xf6'
 }}}

-- 
Ticket URL: <http://ipython.scipy.org/ipython/ipython/ticket/201>
IPython <http://ipython.scipy.org>
The IPython interactive Python system


More information about the Ipython-tickets mailing list