IPython doesn't handle utf8 strings correctly
Bug #290677 reported by
Stephan Peijnik
This bug affects 4 people
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
IPython |
Confirmed
|
Undecided
|
Unassigned | ||
ipython (Debian) |
Confirmed
|
Unknown
|
Bug Description
The original bug came in via bugs.debian.org (http://
It seems that IPython 0.9.1 is also affected by this bug after a quick check. I have included sample output (of IPython 0.9.1) below.
The test in [2] worked correctly (as expected), but [3] and [4] fail, which they obviously should not.
Regards,
Stephan
--snip--
In [1]: import sys
In [2]: 'ä'.decode(
Out[2]: u'\xe4'
In [3]: u'ä'
Out[3]: u'\xc3\xa4'
In [4]: 'ä'
Out[4]: '\xc3\xa4'
Changed in ipython: | |
status: | Unknown → Fix Released |
Changed in ipython (Debian): | |
status: | Fix Released → Confirmed |
To post a comment you must log in.
Commenting the line 2018 in /usr/share/ python- support/ ipython/ IPython/ iplib.py (IPython 0.8.4, Ubuntu 8.10 version) seems to fix this issue. But I don't know if this breaks anything else... in my informal tests it works fine.
1985 def runsource(self, source, filename='<input>', symbol='single'): source. encode( self.stdin_ encoding) source, filename, symbol) error(filename)
[...]
2014 # if the source code has leading blanks, add 'if 1:\n' to it
2015 # this allows execution of indented pasted code. It is tempting
2016 # to add '\n' at the end of source to run commands like ' a=1'
2017 # directly, but this fails for more complicated scenarios
2018 #source=
2019 if source[:1] in [' ', '\t']:
2020 source = 'if 1:\n%s' % source
2021
2022 try:
2023 code = self.compile(
2024 except (OverflowError, SyntaxError, ValueError, TypeError):
2025 # Case 1
2026 self.showsyntax
2027 return None
I'll take a look at the trunk version. Could you confirm if this fix doesn't affect the rest of the program?
Thanks
Marcelo