diff options
| author | Ćukasz Langa <lukasz@langa.pl> | 2021-10-19 22:31:18 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-19 22:31:18 +0200 |
| commit | 5c9cab595e56aeb118bff77ece784dbac30b4338 (patch) | |
| tree | 35ab9e41afc7da8a42c978848823e2d517d0d5de /Lib | |
| parent | 325b2c223453203b2fa9ce7b9bcebdbef03adf70 (diff) | |
| download | cpython-git-5c9cab595e56aeb118bff77ece784dbac30b4338.tar.gz | |
[3.10] bpo-45494: Fix parser crash when reporting errors involving invalid continuation characters (GH-28993) (GH-29070)
There are two errors that this commit fixes:
* The parser was not correctly computing the offset and the string
source for E_LINECONT errors due to the incorrect usage of strtok().
* The parser was not correctly unwinding the call stack when a tokenizer
exception happened in rules involving optionals ('?', [...]) as we
always make them return valid results by using the comma operator. We
need to check first if we don't have an error before continuing..
(cherry picked from commit a106343f632a99c8ebb0136fa140cf189b4a6a57)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Diffstat (limited to 'Lib')
| -rw-r--r-- | Lib/test/test_exceptions.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index 4213dabfd8..4930c57d3f 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -209,6 +209,10 @@ class ExceptionTests(unittest.TestCase): src = src.decode(encoding, 'replace') line = src.split('\n')[lineno-1] self.assertIn(line, cm.exception.text) + + def test_error_offset_continuation_characters(self): + check = self.check + check('"\\\n"(1 for c in I,\\\n\\', 2, 2) def testSyntaxErrorOffset(self): check = self.check |
