Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

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

tcourbon opened this issue Oct 31, 2010 · 4 comments

Comments

@tcourbon
Copy link

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
Copy link
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
Copy link
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
Copy link
Author

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants