Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

%loadpy should cut out encoding declaration #1103

Closed
takluyver opened this Issue · 0 comments

1 participant

@takluyver
Owner

I noticed recently that doing %loadpy on a file with a # coding: utf-8 magic comment causes a problem, because the compiler doesn't like encoding declarations in a unicode string. We should ideally detect this, use it to correctly decode the file ourselves, and then remove the encoding declaration from the code that appears.

Example session:

In [1]: print 123
123

In [2]: %save foo.py 1
The following commands were written to file `foo.py`:
print 123

In [3]: %loadpy foo.py

In [4]: # coding: utf-8
   ...: print 123
  File "<ipython-input-4-8226810be253>", line 0
SyntaxError: encoding declaration in Unicode string (<ipython-input-4-8226810be253>, line 0)
@takluyver takluyver closed this in 0c6c879
@ellisonbg ellisonbg referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@mattvonrocketstein mattvonrocketstein referenced this issue from a commit in mattvonrocketstein/ipython
@takluyver takluyver Strip out encoding declaration in %loadpy
Closes gh-1103
2851037
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.