from __future__ import unicode_literals does not work #786

Closed
olivierverdier opened this Issue Sep 13, 2011 · 4 comments

Projects

None yet

3 participants

@olivierverdier

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
@fperez
IPython member

@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...

@takluyver
IPython member

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.

@takluyver takluyver closed this Sep 13, 2011
@olivierverdier

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... :-/)

@fperez
IPython member

To run the test suite, use

iptest

you can pass it any nose flags

iptest -vvs

or test specific submodules

iptest -v IPython.core
@olivierverdier olivierverdier added a commit to olivierverdier/ipython that referenced this issue Sep 14, 2011
@olivierverdier olivierverdier TST: add future unicode_literals test (#786) 42e2485
@mattvonrocketstein mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
@olivierverdier 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