IPython can't deal with unicode file name. #196

Closed
tcourbon opened this Issue Oct 31, 2010 · 4 comments

Projects

None yet

4 participants

@tcourbon

The following code fail in IPython (last stable version) :

In [1]: f = open(u'/home/thomas/Expérimentations/test.dat')
---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)

/home/thomas/ in ()

IOError: [Errno 2] No such file or directory: u'/home/thomas/Exp\xc3\xa9rimentations/test.dat'

On the standard python interpreter, this work flawlessly. A filepath without unicode character work in both.

@fperez
Member
fperez commented Oct 31, 2010

Thanks for the report. We do have a set of serious unicode problems, thanks for reporting this variant as it will help ensuring we make this a specific test. I hope to tackle the whole unicde mess very soon.

@minrk
Member
minrk commented Oct 31, 2010

What is your default encoding/version? (sys.getdefaultencoding()) And also what is the encoding in your Terminal window?

The normal default with 2.x is ascii, in which case you actually can't do:
u'é' in a Terminal, as far as I know (I get a UnicodeError just typing that)

Note that if you have sys.setdefaultencoding='utf8', then you can type that, but weird things can happen, as I recently learned from Robert Kern.

With utf8 as default encoding, I was able to perform the example you mention:

In [21]: f = open(u"Expérimentations/test.dat")

In [22]: print f.read()
asdf

The bug could be that I think 'Exp\xc3\xa9rimentations' should actually be 'Exp\xa9rimentations'.

Unicode seriously confuses me, so good luck to Fernando working on this.

@tcourbon

I have :

In [1]: import sys

In [2]: sys.getdefaultencoding()
Out[2]: 'ascii'

(Note that on the standard python interpreter I have the same result to sys.getdefaultencoding() )

Also, I don't know if it's relevant but sys.getfilesystemencoding is 'UTF-8'.

Finally I believe that messing around with sys.setdefaultencoding is, well, evil.

Anyway, thanks for the quick answers, I really appreciate the work you do on iPython : it help me for my thesis work.

Cheers !

@takluyver
Member

I think (hope) this should be working again in my unicode-issues branch: #252

@takluyver takluyver closed this Mar 25, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment