cpython/Parser
Lysandros Nikolaou e5fe509054
bpo-42827: Fix crash on SyntaxError in multiline expressions (GH-24140)
When trying to extract the error line for the error message there
are two distinct cases:

1. The input comes from a file, which means that we can extract the
   error line by using `PyErr_ProgramTextObject` and which we already
   do.
2. The input does not come from a file, at which point we need to get
   the source code from the tokenizer:
   * If the tokenizer's current line number is the same with the line
     of the error, we get the line from `tok->buf` and we're ready.
   * Else, we can extract the error line from the source code in the
     following two ways:
     * If the input comes from a string we have all the input
       in `tok->str` and we can extract the error line from it.
     * If the input comes from stdin, i.e. the interactive prompt, we
       do not have access to the previous line. That's why a new
       field `tok->stdin_content` is added which holds the whole input for the
       current (multiline) statement or expression. We can then extract the
       error line from `tok->stdin_content` like we do in the string case above.

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2021-01-14 21:36:30 +00:00
..
asdl.py bpo-40528: Improve and clear several aspects of the ASDL definition code for the AST (GH-19952) 2020-05-06 15:29:32 +01:00
asdl_c.py bpo-1635741: _ast uses PyModule_AddObjectRef() (GH-23146) 2020-11-04 16:37:07 +01:00
myreadline.c bpo-38156: Fix compiler warning in PyOS_StdioReadline() (GH-21721) 2020-08-04 02:38:16 +02:00
parser.c bpo-42860: Remove type error from grammar (GH-24156) 2021-01-07 14:31:25 -08:00
peg_api.c bpo-40939: Rename PyPegen* functions to PyParser* (GH-21016) 2020-06-22 00:47:46 +01:00
pegen.c bpo-42827: Fix crash on SyntaxError in multiline expressions (GH-24140) 2021-01-14 21:36:30 +00:00
pegen.h bpo-42214: Fix check for NOTEQUAL token in the PEG parser for the barry_as_flufl rule (GH-23048) 2020-10-30 23:48:42 +00:00
Python.asdl bpo-40528: Improve and clear several aspects of the ASDL definition code for the AST (GH-19952) 2020-05-06 15:29:32 +01:00
string_parser.c bpo-42806: Fix ast locations of f-strings inside parentheses (GH-24067) 2021-01-03 01:11:41 +00:00
string_parser.h bpo-40939: Remove the old parser (GH-20768) 2020-06-11 17:30:46 +01:00
token.c bpo-35975: Support parsing earlier minor versions of Python 3 (GH-12086) 2019-03-07 12:38:08 -08:00
tokenizer.c bpo-42827: Fix crash on SyntaxError in multiline expressions (GH-24140) 2021-01-14 21:36:30 +00:00
tokenizer.h bpo-42827: Fix crash on SyntaxError in multiline expressions (GH-24140) 2021-01-14 21:36:30 +00:00