diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2024-09-24 11:01:37 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-24 11:01:37 +0300 |
commit | e2f710792b0418b8ca1ca3b8cdf39588c7268495 (patch) | |
tree | 5fa743b6be184b1384cea36bc58e591b4568f52e /Lib/test/test_compiler_codegen.py | |
parent | 3c83f9958c14cd62ad8951c53536f7788745b0ba (diff) | |
download | cpython-e2f710792b0418b8ca1ca3b8cdf39588c7268495.tar.gz cpython-e2f710792b0418b8ca1ca3b8cdf39588c7268495.zip |
gh-124188: Fix PyErr_ProgramTextObject() (GH-124189)
* Detect source file encoding.
* Use the "replace" error handler even for UTF-8 (default) encoding.
* Remove the BOM.
* Fix detection of too long lines if they contain NUL.
* Return the head rather than the tail for truncated long lines.
Diffstat (limited to 'Lib/test/test_compiler_codegen.py')
-rw-r--r-- | Lib/test/test_compiler_codegen.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/test/test_compiler_codegen.py b/Lib/test/test_compiler_codegen.py index d82fb85ed25..8a15c400a44 100644 --- a/Lib/test/test_compiler_codegen.py +++ b/Lib/test/test_compiler_codegen.py @@ -152,5 +152,8 @@ class IsolatedCodeGenTests(CodegenTestCase): def test_syntax_error__return_not_in_function(self): snippet = "return 42" - with self.assertRaisesRegex(SyntaxError, "'return' outside function"): + with self.assertRaisesRegex(SyntaxError, "'return' outside function") as cm: self.codegen_test(snippet, None) + self.assertIsNone(cm.exception.text) + self.assertEqual(cm.exception.offset, 1) + self.assertEqual(cm.exception.end_offset, 10) |