Issue #12451: runpy: run_path() now opens the Python script in binary mode,

instead of text mode using the locale encoding, to support other encodings than
UTF-8 (scripts using the coding cookie).
This commit is contained in:
Victor Stinner 2011-07-04 01:45:39 +02:00
parent bbdc08ea6e
commit 6c47102982
3 changed files with 15 additions and 1 deletions

View file

@ -226,7 +226,7 @@ def _get_code_from_file(fname):
code = read_code(f)
if code is None:
# That didn't work, so try it as normal source code
with open(fname, "rU") as f:
with open(fname, "rb") as f:
code = compile(f.read(), fname, 'exec')
return code