]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-44201: Avoid side effects of "invalid_*" rules in the REPL (GH-26298) (GH-26313)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 22 May 2021 22:23:26 +0000 (15:23 -0700)
committerGitHub <noreply@github.com>
Sat, 22 May 2021 22:23:26 +0000 (23:23 +0100)
commit1fb6b9e91d8685f7eca0fc33402589c65723bd94
treec5900d8a81b1614306fb3e407fbf0026dc15d1f1
parent413df57968e4d612f87722bb8454a66357f84839
bpo-44201: Avoid side effects of "invalid_*" rules in the REPL (GH-26298) (GH-26313)

When the parser does a second pass to check for errors, these rules can
have some small side-effects as they may advance the parser more than
the point reached in the first pass. This can cause the tokenizer to ask
for extra tokens in interactive mode causing the tokenizer to show the
prompt instead of failing instantly.

To avoid this, add a new mode to the tokenizer that is activated in the
second pass and deactivates asking for new tokens when the interactive
line is finished. As the parsing should have reached the last line in
the first pass, the second pass should not need to ask for more tokens.

(cherry picked from commit bd7476dae337e905e7b1bbf33ddb96cc270fdc84)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Include/errcode.h
Misc/NEWS.d/next/Core and Builtins/2021-05-21-21-16-03.bpo-44201.bGaSjt.rst [new file with mode: 0644]
Parser/pegen.c
Parser/tokenizer.c
Parser/tokenizer.h