diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-07-03 23:47:40 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-07-03 23:47:40 (GMT) |
commit | 7d8c8a095a19ea63a313c6b937bc2bbcbc7fd6f9 (patch) | |
tree | 42729a85f88e7b736db721787e3caa2ff855f4f3 /Lib/test/test_runpy.py | |
parent | 3663abab59a397c971fb7e039f5f91b171be12d8 (diff) | |
parent | 6c471029821677e893a203a0127777735ff526c7 (diff) | |
download | cpython-7d8c8a095a19ea63a313c6b937bc2bbcbc7fd6f9.zip cpython-7d8c8a095a19ea63a313c6b937bc2bbcbc7fd6f9.tar.gz cpython-7d8c8a095a19ea63a313c6b937bc2bbcbc7fd6f9.tar.bz2 |
(merge 3.2) 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).
Diffstat (limited to 'Lib/test/test_runpy.py')
-rw-r--r-- | Lib/test/test_runpy.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_runpy.py b/Lib/test/test_runpy.py index c1f96c0..2cede19 100644 --- a/Lib/test/test_runpy.py +++ b/Lib/test/test_runpy.py @@ -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(): |