Open a docker instance (e.g., docker run -ti ubuntu:16.04), create the Python files a.py
# -*- coding: utf-8 -*-
a = 'ö'
and r.py
with open('a.py') as f: exec(f.read())
When executing python r.py, all is file. When using python3, however, one gets the dreaded
Traceback (most recent call last):
File "r.py", line 2, in <module>
exec(f.read())
File "/usr/lib/python3.5/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 31: ordinal not in range(128)
Curiously, I can reproduce this only on docker.
Any hints on what may be going wrong, and how to fix it? (Note that I can only modify r.py.)