diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2021-11-17 23:18:16 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-17 23:18:16 (GMT) |
commit | 0ef308a2890571c850c624fb99ac00f8951363c6 (patch) | |
tree | c3174751e24a1501235090860401965fb9335530 /Lib | |
parent | 87787c8774221c81602b31b0e0dc0678ad494e91 (diff) | |
download | cpython-0ef308a2890571c850c624fb99ac00f8951363c6.zip cpython-0ef308a2890571c850c624fb99ac00f8951363c6.tar.gz cpython-0ef308a2890571c850c624fb99ac00f8951363c6.tar.bz2 |
bpo-45822: Respect PEP 263's coding cookies in the parser even if flags are not provided (GH-29582) (GH-29585)
(cherry picked from commit da20d7401de97b425897d3069f71f77b039eb16f)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_capi.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py index 6b2fe2f..23e65df 100644 --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -926,6 +926,14 @@ class Test_ModuleStateAccess(unittest.TestCase): with self.assertRaises(TypeError): increment_count(1, 2, 3) + def test_Py_CompileString(self): + # Check that Py_CompileString respects the coding cookie + _compile = _testcapi.Py_CompileString + code = b"# -*- coding: latin1 -*-\nprint('\xc2\xa4')\n" + result = _compile(code) + expected = compile(code, "<string>", "exec") + self.assertEqual(result.co_consts, expected.co_consts) + if __name__ == "__main__": unittest.main() |