mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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:
parent
bbdc08ea6e
commit
6c47102982
3 changed files with 15 additions and 1 deletions
|
@ -405,6 +405,16 @@ argv0 = sys.argv[0]
|
|||
msg = "recursion depth exceeded"
|
||||
self.assertRaisesRegex(RuntimeError, msg, run_path, zip_name)
|
||||
|
||||
def test_encoding(self):
|
||||
with temp_dir() as script_dir:
|
||||
filename = os.path.join(script_dir, 'script.py')
|
||||
with open(filename, 'w', encoding='latin1') as f:
|
||||
f.write("""
|
||||
#coding:latin1
|
||||
"non-ASCII: h\xe9"
|
||||
""")
|
||||
result = run_path(filename)
|
||||
self.assertEqual(result['__doc__'], "non-ASCII: h\xe9")
|
||||
|
||||
|
||||
def test_main():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue