]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.9] bpo-45494: Fix parser crash when reporting errors involving invalid continuatio...
authorŁukasz Langa <lukasz@langa.pl>
Wed, 20 Oct 2021 16:51:13 +0000 (18:51 +0200)
committerGitHub <noreply@github.com>
Wed, 20 Oct 2021 16:51:13 +0000 (18:51 +0200)
commit88f4ec88e282bf861f0af2d237e9fe28fbc8deac
tree289d8b70bca2eee134958dfe5b6311c9f3ccf474
parent50e8b2ff0273e81829ed3fa4ab9ef9898fd2b891
[3.9] bpo-45494: Fix parser crash when reporting errors involving invalid continuation characters (GH-28993) (#29071)

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>
NOTE: unlike the cherry-picked original, this commit points at a crazy location
due to a bug in the tokenizer that required a big refactor in 3.10 to fix.
We are leaving as-is for 3.9.
Lib/test/test_exceptions.py
Misc/NEWS.d/next/Core and Builtins/2021-10-16-17-27-48.bpo-45494.vMt1g4.rst [new file with mode: 0644]
Parser/pegen/parse.c
Parser/pegen/pegen.c
Tools/peg_generator/pegen/c_generator.py