Comment 10 for bug 339642

Revision history for this message
Brian Granger (ellisonbg) wrote : Re: [Bug 339642] Re: unicode bug - encoding input

Definitely, I don't like playing whack-a-mole blind. These types of
bug fixes definitely need tests before fixes get commited.

Brian

On Tue, Apr 14, 2009 at 12:20 AM, Fernando Perez <email address hidden> wrote:
> Can anyone provide a set of *tests* that we can actually run
> automatically for this? Honestly, until we have actual tests, this is
> like playing whack-a-mole blind: the problems will just keep
> resurfacing... What we need is a test file for unicode that can be
> run reliably, by anyone, and that shows the various issues...
>
> As I said earlier, it's quite possible that the various proposed fixes
> work for *someone*, but without actual tests that we can include,
> there's no way to know what they may break for someone else (as has
> happened in the past).
>
> Sorry to seem like a curmudgeon: I really appreciate people
> contributing ideas and even code. But we need to fix these unicode
> problems the right way, else we'll be hunting them forever.
>
> --
> unicode bug - encoding input
> https://bugs.launchpad.net/bugs/339642
> You received this bug notification because you are a member of IPython
> Developers, which is subscribed to IPython.
>
> Status in IPython - Enhanced Interactive Python: New
>
> Bug description:
> Default Python shell:
>
>>>> u'абвгд'
> u'\u0430\u0431\u0432\u0433\u0434'
>
> IPython 0.9.1:
>
>>>> u'абвгд'
> u'\xd0\xb0\xd0\xb1\xd0\xb2\xd0\xb3\xd0\xb4'
>>>> 'абвгд'.decode('utf8')
> u'\u0430\u0431\u0432\u0433\u0434'
>
> sys.stdin.encoding is 'UTF-8'.
>
> How to fix: remove the line No.2022 from IPython/iplib.py (for 0.9.1 release). Here it is:
>
> --- a/iplib.py
> +++ b/iplib.py
> @@ -2019,7 +2019,6 @@
> # this allows execution of indented pasted code. It is tempting
> # to add '\n' at the end of source to run commands like ' a=1'
> # directly, but this fails for more complicated scenarios
> - source=source.encode(self.stdin_encoding)
> if source[:1] in [' ', '\t']:
> source = 'if 1:\n%s' % source
>
>
> I didn't find any intoduced bugs by a quick check.
>
> Additionaly, I checked ipython-wx and ipythonx - latter doesn't have this bug.
>

--
Brian E. Granger, Ph.D.
Assistant Professor of Physics
Cal Poly State University, San Luis Obispo
<email address hidden>
<email address hidden>