UnicodeDecodeError in Notebook Server if Worksheet is set to 'python' instead of 'sage'

asked 2015-03-12 07:02:07 -0500

Petr gravatar image

updated 2015-03-12 07:03:00 -0500

Hello!

I have a worksheet with non-ascii characters in the source code (utf-8 comments). If I have 'sage' selected in the combo-box on top of the worksheet then "Save worksheet to a file" works well. But if I change this to 'python' than calling "Save worksheet to a file" leads to a UnicodeDecodeError:

'ascii' codec can't decode byte 0xd0 in position 6: ordinal not in range(128)
Traceback (most recent call last):
  File "/home/sage/sage-6.5/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/sage/sage-6.5/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/sage/sage-6.5/local/lib/python2.7/site-packages/sagenb-0.11.4-py2.7.egg/sagenb/flask_version/decorators.py", line 22, in wrapper
    return f(*args, **kwds)
  File "/home/sage/sage-6.5/local/lib/python2.7/site-packages/sagenb-0.11.4-py2.7.egg/sagenb/flask_version/worksheet.py", line 48, in wrapper
    return f(username, id, **kwds)
  File "/home/sage/sage-6.5/local/lib/python2.7/site-packages/sagenb-0.11.4-py2.7.egg/sagenb/flask_version/worksheet.py", line 137, in wrapper
    return f(*args, **kwds)
  File "/home/sage/sage-6.5/local/lib/python2.7/site-packages/sagenb-0.11.4-py2.7.egg/sagenb/flask_version/worksheet.py", line 938, in worksheet_download
    return unconditional_download(worksheet, title)
  File "/home/sage/sage-6.5/local/lib/python2.7/site-packages/sagenb-0.11.4-py2.7.egg/sagenb/flask_version/worksheet.py", line 950, in unconditional_download
    g.notebook.export_worksheet(worksheet.filename(), filename, title)
  File "/home/sage/sage-6.5/local/lib/python2.7/site-packages/sagenb-0.11.4-py2.7.egg/sagenb/notebook/notebook.py", line 748, in export_worksheet
    S.export_worksheet(username, id_number, output_filename, title=title)
  File "/home/sage/sage-6.5/local/lib/python2.7/site-packages/sagenb-0.11.4-py2.7.egg/sagenb/storage/filesystem_storage.py", line 491, in export_worksheet
    f.write(old_heading + g.read())
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 6: ordinal not in range(128)
edit retag flag offensive close merge delete