%run
ning a python file marked with # -*- coding: utf-8 -*-
and saved in a non-utf8 format can crash ipython (return to shell).
To get the crash, the file must :
Here is a small script reproducing this, saved in ISO-8859-15, together with the stack trace:
files.zip
%run wrong_encoding.py
...
... <long trace>
...
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 78: invalid continuation byte
python3 -c "import IPython; print(IPython.sys_info())"
{'commit_hash': '5c9c918',
'commit_source': 'installation',
'default_encoding': 'UTF-8',
'ipython_path': '/usr/lib/python3.4/site-packages/IPython',
'ipython_version': '5.1.0',
'os_name': 'posix',
'platform': 'Linux-3.16.7-42-desktop-x86_64-with-SuSE-13.2-x86_64',
'sys_executable': '/usr/bin/python3',
'sys_platform': 'linux',
'sys_version': '3.4.5 (default, Jul 03 2016, 13:55:08) [GCC]'}
Of course, the file should have been saved in the correct format, in the first place.
But ideally the session would not be lost, and a more informative message would be issued.
I count thirteen chained tracebacks - I think getting that many without using recursion should get you some kind of prize. ;-)
If the file name is not easy to reach, then here is the command I used to track down the culprit:
find . -name "*.py" -exec file {} \; | grep -v ASCII | grep -v UTF-8 | grep -v empty
Most helpful comment
I count thirteen chained tracebacks - I think getting that many without using recursion should get you some kind of prize. ;-)