You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ LC_CTYPE="C.UTF-8" python2.7 -m unittest discover
......
----------------------------------------------------------------------
Ran 6 tests in 0.020s
OK
$ LC_CTYPE="POSIX" python2.7 -m unittest discover
.E....
======================================================================
ERROR: test_aleksandra_slapik_44 (test.test_sagenb_writer.ReadSageNB)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/infinity0/var/lib/sage/sagenb-export/test/test_sagenb_writer.py", line 39, in test_aleksandra_slapik_44
ipynb.write(self.tmp_filename(u'WDI projekt - R\xf3\u017cankowski, Kie\u0142pi\u0144ski, Kozok.ipynb'))
File "/home/infinity0/var/lib/sage/sagenb-export/sagenb_export/ipynb_writer.py", line 58, in write
write(ipynb, filename)
File "/usr/lib/python2.7/dist-packages/nbformat/__init__.py", line 163, in write
with io.open(fp, 'w', encoding='utf-8') as f:
UnicodeEncodeError: 'ascii' codec can't encode characters in position 41-42: ordinal not in range(128)
----------------------------------------------------------------------
Ran 6 tests in 0.020s
FAILED (errors=1)
1
This is because you pass a unicode string type as a filename. Python will implicitly try to encode this using LC_CTYPE, which doesn't support that particular value. You can fix this in several ways, I'm not sure which way you prefer:
Say that IpynbWriter.write can only accept byte filenames, and do the encode('utf-8') in the test. This is probably the simplest.
Say that IpynbWriter.write can accept unicode string filenames too, and do encode('utf-8') in there, if it's a string type.
Add a filename_encoding param to IpynbWriter.write.
The text was updated successfully, but these errors were encountered:
On further investigation it looks like this is more a problem with nbformat.write - even if you pass a byte path here, that function will not accept it - it only accepts string filenames or file objects. I'll go file a bug there too instead.
This is because you pass a unicode string type as a filename. Python will implicitly try to encode this using LC_CTYPE, which doesn't support that particular value. You can fix this in several ways, I'm not sure which way you prefer:
IpynbWriter.write
can only acceptbyte
filenames, and do theencode('utf-8')
in the test. This is probably the simplest.IpynbWriter.write
can accept unicode string filenames too, and doencode('utf-8')
in there, if it's a string type.filename_encoding
param toIpynbWriter.write
.The text was updated successfully, but these errors were encountered: