Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


%loadpy should cut out encoding declaration #1103

takluyver opened this Issue · 0 comments

1 participant

Thomas Kluyver
Thomas Kluyver

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

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

In [3]: %loadpy

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)
Thomas Kluyver takluyver closed this in 0c6c879
Brian E. Granger ellisonbg referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
matthew von rocketstein mattvonrocketstein referenced this issue from a commit in mattvonrocketstein/ipython
Thomas Kluyver takluyver Strip out encoding declaration in %loadpy
Closes gh-1103
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.