From e2f710792b0418b8ca1ca3b8cdf39588c7268495 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Tue, 24 Sep 2024 11:01:37 +0300 Subject: 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. --- Lib/test/test_compiler_codegen.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Lib/test/test_compiler_codegen.py') 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) -- cgit v1.2.3