mirror of
https://github.com/python/cpython.git
synced 2025-10-13 10:23:28 +00:00
bpo-40985: Show correct SyntaxError text when last line has a LINECONT (GH-20888)
When a file ends with a line that contains a line continuation character
the text of the emitted SyntaxError is empty, contrary to the old
parser, where the error text contained the text of the last line.
(cherry picked from commit 113e2b0a07
)
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
This commit is contained in:
parent
bc996c67b7
commit
097b8b6d52
3 changed files with 13 additions and 4 deletions
|
@ -52,10 +52,14 @@ class EOFTestCase(unittest.TestCase):
|
|||
file_name = script_helper.make_script(temp_dir, 'foo', '\\')
|
||||
rc, out, err = script_helper.assert_python_failure(file_name)
|
||||
self.assertIn(b'unexpected EOF while parsing', err)
|
||||
self.assertIn(b'line 2', err)
|
||||
self.assertIn(b'\\', err)
|
||||
|
||||
file_name = script_helper.make_script(temp_dir, 'foo', 'y = 6\\')
|
||||
rc, out, err = script_helper.assert_python_failure(file_name)
|
||||
self.assertIn(b'unexpected EOF while parsing', err)
|
||||
self.assertIn(b'line 2', err)
|
||||
self.assertIn(b'y = 6\\', err)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue