Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

%run does not work with non-ascii characeters in path #818

Closed
jstenar opened this Issue · 10 comments

4 participants

@jstenar
Collaborator

When I try to %run a script when there are non-ascii characters in the path I get unicode decode errors.

In [4]: %run scriptåäö.py
---------------------------------------------------------------------------
UnicodeEncodeError                        Traceback (most recent call last)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 35-37: ordinal not in range(128)

As far as I can tell the problem is that execfile does not tolerate non-ascii characters in the path.
I have a fix implemented in my execfile branch where I have switched to using exec and compile instead.

/Jörgen

@minrk
Owner

It might make sense to just encode unicode filenames with sys.getfilesystemencoding() before passing to execfile.

@jstenar
Collaborator
@minrk
Owner

Why would a mixture of Greek and Latin make a difference? I can (and do) have Greek, Latin, and Japanese filenames on my system, all of which are encoded with the filesystem encoding, and work just fine with execfile.

Does Windows have different encodings associated on a per-file basis?

@jstenar
Collaborator
@fperez
Owner

@jstenar, what's your take on this then moving forward? If the approach suggested by @minrk isnt' enough on win32, then we may need to go with yours. Keep in mind we have a function called safe_execfile() that we make all our execfile calls through. That would be the right point to put more layers of safety in.

And if the more manual approach you describe is truly necessary on win32, we can just do it conditionally: use the simpler method Min suggested in general, but specialize to you manual method on win32.

If that sounds reasonable, feel free to whip up a PR for it. The window before 0.12 is closing though... I'd like to try to close as many of the open PRs as possible and start freezing for beta testing and stabilization.

@jstenar jstenar referenced this issue
Merged

Execfile #896

@jstenar
Collaborator

I created PR #896

I think it makes more sense to put it in the py3compat module because otherwise I will have to put py3 related logic in safe_execfile as well which seems awkward to me.

Do you have any ideas on how to test this? safe_execfile is supposed to swallow all exceptions so how do I check for my error case?

/Jörgen

@fperez
Owner
@jstenar
Collaborator
@takluyver
Owner

@jstenar: The PR relating to this is merged now - can we close this issue?

@jstenar
Collaborator
@takluyver takluyver closed this
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.