mirror of
https://github.com/python/cpython.git
synced 2025-11-09 18:11:38 +00:00
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.
This commit is contained in:
parent
3c83f9958c
commit
e2f710792b
6 changed files with 328 additions and 117 deletions
|
|
@ -152,5 +152,8 @@ def g():
|
|||
|
||||
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue