summaryrefslogtreecommitdiff
path: root/Lib/test/test_compile.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-06-18 13:56:16 +0300
committerSerhiy Storchaka <storchaka@gmail.com>2016-06-18 13:56:16 +0300
commitf95de0e8cc259b1ccb6b604a0ed74bb7894f4b2b (patch)
tree24ae043565544e6b02d39b127439b987b144d0d8 /Lib/test/test_compile.py
parent2fec611a70ba862a4127b7656a6d98d48850c3af (diff)
parent9305d83425e2ec63b2769336907dd07b3151cd5f (diff)
downloadcpython-git-f95de0e8cc259b1ccb6b604a0ed74bb7894f4b2b.tar.gz
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.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index e0fdee3349..824e843914 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"""