summaryrefslogtreecommitdiffstats
path: root/Parser/pegen/parse_string.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-40998: Address compiler warnings found by ubsan (GH-20929)Miss Islington (bot)2020-11-181-0/+3
| | | | | | | | Signed-off-by: Christian Heimes <christian@python.org> Automerge-Triggered-By: GH:tiran (cherry picked from commit 07f2adedf0940b06d136208ec386d69b7d2d5b43) Co-authored-by: Christian Heimes <christian@python.org>
* Fix trivial typo in the PEG string parser (GH-21508)Miss Islington (bot)2020-07-161-1/+1
| | | | | (cherry picked from commit 0275e0452a773976827c2b9bd1e598ee08e2d7f5) Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
* Fix possibly-unitialized warning in string_parser.c. (GH-21503)Miss Islington (bot)2020-07-161-15/+16
| | | | | | | | | | | | | | | | | | | | | | | GCC says ``` ../cpython/Parser/string_parser.c: In function ‘fstring_find_expr’: ../cpython/Parser/string_parser.c:404:93: warning: ‘cols’ may be used uninitialized in this function [-Wmaybe-uninitialized] 404 | p2->starting_col_offset = p->tok->first_lineno == p->tok->lineno ? t->col_offset + cols : cols; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ ../cpython/Parser/string_parser.c:384:16: note: ‘cols’ was declared here 384 | int lines, cols; | ^~~~ ../cpython/Parser/string_parser.c:403:45: warning: ‘lines’ may be used uninitialized in this function [-Wmaybe-uninitialized] 403 | p2->starting_lineno = t->lineno + lines - 1; | ~~~~~~~~~~~~~~~~~~^~~ ../cpython/Parser/string_parser.c:384:9: note: ‘lines’ was declared here 384 | int lines, cols; | ^~~~~ ``` and, indeed, if `PyBytes_AsString` somehow fails, lines & cols will not be initialized. (cherry picked from commit 2ad7e9c011b7606c5c7307176df07419a0e60134) Co-authored-by: Benjamin Peterson <benjamin@python.org>
* [3.9] bpo-41076: Pre-feed the parser with the f-string expression location ↵Pablo Galindo2020-06-281-242/+22
| | | | | | (GH-21054) (GH-21190) This commit changes the parsing of f-string expressions with the new parser. The parser gets pre-fed with the location of the expression itself (not the f-string, which was what we were doing before). This allows us to completely skip the shifting of the AST nodes after the parsing is completed.. (cherry picked from commit 1f0f4abb110b9fbade6175842b6a26ab0b8df6dd)
* [3.9] bpo-41132: Use pymalloc allocator in the f-string parser (GH-21173) ↵Lysandros Nikolaou2020-06-271-7/+7
| | | | | | | (GH-21183) (cherry picked from commit 6dcbc2422de9e2a7ff89a4689572d84001e230b2) Automerge-Triggered-By: @pablogsal
* [3.9] Improve readability and style in parser files (GH-20884) (GH-20885)Pablo Galindo2020-06-151-98/+130
| | | | | (cherry picked from commit fb61c42) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-40904: Fix segfault in the new parser with f-string containing yield ↵Miss Islington (bot)2020-06-081-0/+3
| | | | | | | statements with no value (GH-20701) (cherry picked from commit 972ab0327675e695373fc6272d5ac24e187579ad) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-40883: Fix memory leak in fstring_compile_expr in parse_string.c (GH-20667)Miss Islington (bot)2020-06-061-0/+2
| | | | | (cherry picked from commit a54096e30523534e8eebb8dc1011b4536ed237a8) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* [3.9] bpo-40614: Respect feature version for f-string debug expressions ↵Pablo Galindo2020-05-271-0/+5
| | | | | | | | | (GH-20196) (GH-20464) Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com> Co-authored-by: Pablo Galindo <pablogsal@gmail.com> (cherry picked from commit c116c94) Co-authored-by: Shantanu <hauntsaninja@users.noreply.github.com>
* [3.9] bpo-38964: Print correct filename on a SyntaxError in an fstring ↵Lysandros Nikolaou2020-05-261-5/+2
| | | | | | | | | | | (GH-20399) (GH-20404) When a `SyntaxError` in the expression part of a fstring is found, the filename attribute of the `SyntaxError` is always `<fstring>`. With this commit, it gets changed to always have the name of the file the fstring resides in. Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>. (cherry picked from commit f7b1e461567e5e3fa3ba46f589d9edc1b45b2dd0)
* bpo-40334: Fix error location upon parsing an invalid string literal (GH-19962)Lysandros Nikolaou2020-05-071-14/+24
| | | | | | | When parsing a string with an invalid escape, the old parser used to point to the beginning of the invalid string. This commit changes the new parser to match that behaviour, since it's currently pointing to the end of the string (or to be more precise, to the beginning of the next token).
* bpo-40334: Add support for feature_version in new PEG parser (GH-19827)Lysandros Nikolaou2020-05-011-1/+9
| | | | | | | | | | | | | | | | | | | `ast.parse` and `compile` support a `feature_version` parameter that tells the parser to parse the input string, as if it were written in an older Python version. The `feature_version` is propagated to the tokenizer, which uses it to handle the three different stages of support for `async` and `await`. Additionally, it disallows the following at parser level: - The '@' operator in < 3.5 - Async functions in < 3.5 - Async comprehensions in < 3.6 - Underscores in numeric literals in < 3.6 - Await expression in < 3.5 - Variable annotations in < 3.6 - Async for-loops in < 3.5 - Async with-statements in < 3.5 - F-strings in < 3.6 Closes we-like-parsers/cpython#124.
* bpo-40334: Fix shifting of nested f-strings in the new parser (GH-19771)Lysandros Nikolaou2020-04-291-0/+9
| | | `JoinedStr`s and `FormattedValue also needs to be shifted, in order to correctly compute the location information of nested f-strings.
* bpo-40334: Support CO_FUTURE_BARRY_AS_BDFL in the new parser (GH-19721)Pablo Galindo2020-04-271-1/+1
| | | This commit also allows to pass flags to the new parser in all interfaces and fixes a bug in the parser generator that was causing to inline rules with actions, making them disappear.
* Compile extensions in test_peg_generator with C99 (GH-19668)Pablo Galindo2020-04-231-14/+10
|
* bpo-40334: Fix errors in parse_string.c with old compilers (GH-19666)Pablo Galindo2020-04-221-10/+14
|
* bpo-40334: PEP 617 implementation: New PEG parser for CPython (GH-19503)Pablo Galindo2020-04-221-0/+1387
Co-authored-by: Guido van Rossum <guido@python.org> Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>