diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-06-18 10:53:36 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-06-18 10:53:36 (GMT) |
commit | 9305d83425e2ec63b2769336907dd07b3151cd5f (patch) | |
tree | af956a2eff3d5241bfa64dd3dc2890fb44896ada /Lib/test/test_compile.py | |
parent | bae5d81f5d1f388aad48c2ce1aee8682b157e1bd (diff) | |
download | cpython-9305d83425e2ec63b2769336907dd07b3151cd5f.zip cpython-9305d83425e2ec63b2769336907dd07b3151cd5f.tar.gz cpython-9305d83425e2ec63b2769336907dd07b3151cd5f.tar.bz2 |
Issue #26754: PyUnicode_FSDecoder() accepted a filename argument encoded as
an iterable of integers. Now only strings and byte-like objects are accepted.
Diffstat (limited to 'Lib/test/test_compile.py')
-rw-r--r-- | Lib/test/test_compile.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py index e0fdee3..824e843 100644 --- a/Lib/test/test_compile.py +++ b/Lib/test/test_compile.py @@ -472,6 +472,13 @@ if 1: d = {f(): f(), f(): f()} self.assertEqual(d, {1: 2, 3: 4}) + def test_compile_filename(self): + for filename in ('file.py', b'file.py', + bytearray(b'file.py'), memoryview(b'file.py')): + code = compile('pass', filename, 'exec') + self.assertEqual(code.co_filename, 'file.py') + self.assertRaises(TypeError, compile, 'pass', list(b'file.py'), 'exec') + @support.cpython_only def test_same_filename_used(self): s = """def f(): pass\ndef g(): pass""" |