Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

from __future__ import unicode_literals does not work #786

Closed
olivierverdier opened this Issue · 4 comments

3 participants

Olivier Verdier Fernando Perez Thomas Kluyver
Olivier Verdier

Works in the Python console

When calling from __future__ import unicode_literals in the standard python console, the result is as follows:

>>> len('é') # standard Python: strings are byte strings
2
>>> from __future__ import unicode_literals
>>> len('é') # strings are now unicode strings:
1

Does not work in IPython

In IPython, it doesn't work:

In [1]: from __future__ import unicode_literals

In [2]: len('é')
Out[2]: 2

Does not work In IPython via the config file either

It does not work either when the future import is placed inside the ipython_config.py file:

c.InteractiveShellApp.exec_lines = ['from __future__ import division, unicode_literals' ]

The problem remains:

In [1]: len('é')
Out[1]: 2
Fernando Perez
Owner

@takluyver, you've had the most do do with our unicode machinery as of late. Does anything quick come to mind on this one? I'm assigning it to 0.12 so we try to ship a release that's as solid as possible on the unicode front...

Thomas Kluyver
Owner

What version were you trying with? I've just tried with master, and it works. I think this is the same root cause as #777, which was closed yesterday (by PR #784). Essentially, __future__ imports only affected compiling and executing code, not parsing it, until that was merged. A nasty oversight, I know.

Closing for now because I think it's already fixed in master, but please reopen it if you can replicate it with a fresh pull.

Thomas Kluyver takluyver closed this
Olivier Verdier

ah, you are right, I was using version .11. It is fixed in master indeed. But perhaps it would be worth writing a little test to check this?

(I'll try to do that when I've figured out how to run the IPython test suite... :-/)

Fernando Perez
Owner

To run the test suite, use

iptest

you can pass it any nose flags

iptest -vvs

or test specific submodules

iptest -v IPython.core
Olivier Verdier olivierverdier referenced this issue from a commit in olivierverdier/ipython
Olivier Verdier olivierverdier TST: add future unicode_literals test (#786) 42e2485
Brian E. Granger ellisonbg referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Brian E. Granger ellisonbg referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
matthew von rocketstein mattvonrocketstein referenced this issue from a commit in mattvonrocketstein/ipython
Olivier Verdier olivierverdier TST: add future unicode_literals test (#786) 76d224d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.