summaryrefslogtreecommitdiffstats
path: root/Parser/parser.c
Commit message (Collapse)AuthorAgeFilesLines
* [3.10] gh-102416: Do not memoize incorrectly loop rules in the parser ↵Pablo Galindo Salgado2023-03-061-176/+0
| | | | (GH-102467). (#102474)
* [3.10] gh-101046: Fix a potential memory leak in the parser when raising ↵Pablo Galindo Salgado2023-01-161-0/+88
| | | | | MemoryError (GH-101051). (#101086) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* [3.10] gh-94996: Disallow lambda pos only params with feature_version < (3, ↵Shantanu2022-08-121-2/+2
| | | | | | | | | 8) (GH-95934) (GH-95938) (cherry picked from commit a965db37f27ffb232312bc13d9a509f0d93fcd20) Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Automerge-Triggered-By: GH:lysnikolaou
* [3.10] gh-94996: Disallow parsing pos only params with feature_version < (3, ↵Shantanu2022-08-121-2/+2
| | | | | | | | | 8) (GH-95935) (cherry picked from commit https://github.com/python/cpython/commit/b5e3ea286289fcad12be78480daf3756e350f69f) Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Automerge-Triggered-By: GH:lysnikolaou
* [3.10] gh-94949: Disallow parsing parenthesised ctx mgr with old ↵Shantanu2022-07-191-1/+1
| | | | | | | feature_version (GH-94950) (#94990) (cherry picked from commit 0daba822212cd5d6c63384a27f390f0945330c2b) Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
* [3.10] gh-94947: Disallow parsing walrus with feature_version < (3, 8) ↵Shantanu2022-07-181-1/+1
| | | | | | | | | | | | | | (GH-94948) (#94969) * gh-94947: Disallow parsing walrus with feature_version < (3, 8) * oops, commit the parser * 📜🤖 Added by blurb_it. Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>. (cherry picked from commit ae0be5a53bb4caee3de4888341addd9c94133f2d) Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
* [3.10] gh-94192: Fix error for dictionary literals with invalid expression ↵wookie1842022-06-271-217/+282
| | | | | as value. (GH-94304) (#94344) Co-authored-by: wookie184 <wookie1840@gmail.com>
* [3.10] gh-92858: Improve error message for some suites with syntax error ↵Pablo Galindo Salgado2022-06-231-293/+431
| | | | | | | | | before ':' (GH-92894). (#94183) (cherry picked from commit 2fc83ac3afa161578200dbf8d823a20e0801c0c0) Co-authored-by: wookie184 <wookie1840@gmail.com> Co-authored-by: wookie184 <wookie1840@gmail.com>
* [3.10] gh-93671: Avoid exponential backtracking in deeply nested sequence ↵Pablo Galindo Salgado2022-06-101-0/+10
| | | | | | | | patterns in match statements (GH-93680) (#93690) Co-authored-by: Łukasz Langa <lukasz@langa.pl>. (cherry picked from commit 53a8b17895e91d08f76a2fb59a555d012cd85ab4) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* [3.10] Backport bpo-47212 (GH-32302) to Python 3.10 (GH-32334)Matthieu Dartiailh2022-04-051-3/+3
| | | | | | | | | (cherry picked from commit aa0f056a00c4bcaef83d729e042359ddae903382) # Conflicts: # Grammar/python.gram # Parser/action_helpers.c Automerge-Triggered-By: GH:pablogsal
* [3.10] Allow the parser to avoid nested processing of invalid rules ↵Pablo Galindo Salgado2022-02-101-910/+900
| | | | | | | (GH-31252). (GH-31257) (cherry picked from commit 390459de6db1e68b79c0897cc88c0d562693ec5c) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* [3.10] bpo-46707: Avoid potential exponential backtracking in some syntax ↵Pablo Galindo Salgado2022-02-101-883/+888
| | | | | | | errors (GH-31241). (GH-31242) (cherry picked from commit b71dc71905ab674ccaa4a56230d17a28f61c325c) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* [3.10] bpo-46110: Add a recursion check to avoid stack overflow in the PEG ↵Pablo Galindo Salgado2021-12-201-3069/+4402
| | | | | | | | parser (GH-30177) (GH-30214) Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>. (cherry picked from commit e9898bf153d26059261ffef11f7643ae991e2a4c) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* bpo-45866: pegen strips directory of "generated from" header (GH-29777) ↵Victor Stinner2021-11-261-1/+1
| | | | | | | | | (GH-29792) "make regen-all" now produces the same output when run from a directory other than the source tree: when building Python out of the source tree. (cherry picked from commit 253b7a0a9fef1d72a4cb87b837885576e68e917c)
* [3.10] bpo-45727: Only trigger the 'did you forgot a comma' error suggestion ↵Pablo Galindo Salgado2021-11-251-1/+1
| | | | | | | if inside parentheses. (GH-29767) Backport of GH-29757 Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* [3.10] bpo-45727: Make the syntax error for missing comma more consistent ↵Pablo Galindo Salgado2021-11-201-327/+260
| | | | | | | (GH-29427) (GH-29647) (cherry picked from commit 546cefcda75d7150b55c8bc1724bea35a1e12890) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* [3.10] bpo-45716: Improve the error message when using True/False/None as ↵Pablo Galindo Salgado2021-11-161-572/+678
| | | | | | | keywords in a call (GH-29413). (GH-29428) (cherry picked from commit e2d65630f36712dbdbf7711520c985c526a5cc25) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* [3.10] bpo-44257: fix "assigment_expr" typo + regenerate the grammar, and ↵Pablo Galindo Salgado2021-11-041-60/+60
| | | | | | | | remove unused imports (GH-29393) (GH-29395) Co-authored-by: Wim Glenn <wglenn@jumptrading.com>. (cherry picked from commit 762173c6709f5cf3b59cbbe47d4e6fafbfe7ec2a) Co-authored-by: wim glenn <wim.glenn@gmail.com>
* [3.10] bpo-45494: Fix parser crash when reporting errors involving invalid ↵Łukasz Langa2021-10-191-120/+120
| | | | | | | | | | | | | | | 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>
* bpo-43914: Correctly highlight SyntaxError exceptions for invalid generator ↵Miss Islington (bot)2021-09-271-3/+3
| | | | | | | expression in function calls (GH-28576) (cherry picked from commit e5f13ce5b48b551c09fdd0faeafa6ecf860de51c) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* bpo-44947: Refine the syntax error for trailing commas in import statements ↵Miss Islington (bot)2021-08-181-5/+8
| | | | | | | (GH-27814) (cherry picked from commit b2f68b190035540872072ac1d2349e7745e85596) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* [3.10] bpo-44838: Refine the custom syntax errors for invalid 'if' ↵Pablo Galindo Salgado2021-08-051-553/+610
| | | | | | | | | | | expressions (GH-27615). (GH-27616) … (cherry picked from commit f5cbea6b1b5fc39cca377c6cc93f222916015fc4) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com> Automerge-Triggered-By: GH:lysnikolaou
* bpo-44792: Improve syntax errors for if expressions (GH-27506) (GH-27565)Miss Islington (bot)2021-08-021-0/+33
| | | | | (cherry picked from commit 28b6dc9dd5d1ce6f8aff7e06d4ef9afdc2bc8332) Co-authored-by: Miguel Brito <5544985+miguendes@users.noreply.github.com>
* bpo-34013: Don't consider a grouped expression when reporting legacy print ↵Miss Islington (bot)2021-08-011-5/+7
| | | | | | | syntax errors (GH-27521) (cherry picked from commit 208a7e957b812ad3b3733791845447677a704f3e) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* bpo-34013: Move the Python 2 hints from the exception constructor to the ↵Miss Islington (bot)2021-07-271-7/+7
| | | | | | | parser (GH-27392) (cherry picked from commit ecc3c8e4216958d85385bf2467441c975128f26c) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* [3.10] bpo-34013: Generalize the invalid legacy statement error message ↵Pablo Galindo Salgado2021-07-271-244/+310
| | | | | | | (GH-27389). (GH-27391) (cherry picked from commit 6948964ecf94e858448dd28eea634317226d2913) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* bpo-44456: Improve the syntax error when mixing keyword and positional ↵Miss Islington (bot)2021-06-241-464/+628
| | | | | | | patterns (GH-26793) (cherry picked from commit 0acc258fe6f0ec200ca2f6f9294adbf52a244802) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* [3.10] bpo-44368: Improve syntax errors with invalid as pattern targets ↵Pablo Galindo2021-06-181-213/+313
| | | | | | | (GH-26632) (GH-26792) (cherry picked from commit 05073036dcecefc00b0c3e7397601809da41e2f1) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-44385: Remove unused grammar rules (GH-26655)Miss Islington (bot)2021-06-101-1256/+791
| | | | | | Automerge-Triggered-By: GH:lysnikolaou (cherry picked from commit e7b4644607789848f9752a3bd20ff216e25b4156) Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
* [3.10] bpo-44305: Improve syntax error for try blocks without except or ↵Pablo Galindo2021-06-031-269/+358
| | | | | | | finally (GH-26523) (GH-26524) (cherry picked from commit b250f89bb7e05e72a4641d44b988866b919575db) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-44180: Fix edge cases in invalid assigment rules in the parser (GH-26283)Miss Islington (bot)2021-05-211-1171/+1401
| | | | | | | | | | | | | | | | | | The invalid assignment rules are very delicate since the parser can easily raise an invalid assignment when a keyword argument is provided. As they are very deep into the grammar tree, is very difficult to specify in which contexts these rules can be used and in which don't. For that, we need to use a different version of the rule that doesn't do error checking in those situations where we don't want the rule to raise (keyword arguments and generator expressions). We also need to check if we are in left-recursive rule, as those can try to eagerly advance the parser even if the parse will fail at the end of the expression. Failing to do this allows the parser to start parsing a call as a tuple and incorrectly identify a keyword argument as an invalid assignment, before it realizes that it was not a tuple after all. (cherry picked from commit c878a9796841c1f4726e6dd5ac49a478af4c8504) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-44168: Fix error message in the parser for keyword arguments for invalid ↵Miss Islington (bot)2021-05-191-541/+584
| | | | | | | | | expressions (GH-26210) (GH-26247) (cherry picked from commit 33c0c90dea06fda1df99482521559ebef7210bea) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com> Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-43149: Correct the syntax error message for multiple exception types ↵Miss Islington (bot)2021-05-091-1/+1
| | | | | | | | | | (GH-25996) GH-25997) Automerge-Triggered-By: GH:pablogsal (cherry picked from commit 6692dc1ca99fb34a19d0a4b93cf8e10619490001) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com> Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-43892: Validate the first term of complex literal value patterns (GH-25735)Brandt Bucher2021-04-301-395/+513
|
* bpo-43892: Make match patterns explicit in the AST (GH-25585)Nick Coghlan2021-04-291-739/+1272
| | | Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
* bpo-43914: Highlight invalid ranges in SyntaxErrors (#25525)Pablo Galindo2021-04-231-460/+550
| | | | | | | | | | | | | | | | | To improve the user experience understanding what part of the error messages associated with SyntaxErrors is wrong, we can highlight the whole error range and not only place the caret at the first character. In this way: >>> foo(x, z for z in range(10), t, w) File "<stdin>", line 1 foo(x, z for z in range(10), t, w) ^ SyntaxError: Generator expression must be parenthesized becomes >>> foo(x, z for z in range(10), t, w) File "<stdin>", line 1 foo(x, z for z in range(10), t, w) ^^^^^^^^^^^^^^^^^^^^ SyntaxError: Generator expression must be parenthesized
* bpo-43859: Improve the error message for IndentationError exceptions (GH-25431)Pablo Galindo2021-04-211-541/+1975
|
* bpo-43823: Fix location of one of the errors for invalid dictionary literals ↵Pablo Galindo2021-04-151-1/+1
| | | | (GH-25427)
* bpo-43822: Improve syntax errors for missing commas (GH-25377)Pablo Galindo2021-04-151-637/+775
|
* bpo-43823: Improve syntax errors for invalid dictionary literals (GH-25378)Pablo Galindo2021-04-151-364/+778
|
* bpo-43797: Handle correctly invalid assignments inside function calls and ↵Pablo Galindo2021-04-131-6/+6
| | | | generators (GH-25390)
* Ensure that early = are not matched by the parser as invalid comparisons ↵Pablo Galindo2021-04-131-318/+413
| | | | (GH-25375)
* bpo-43797: Improve syntax error for invalid comparisons (#25317)Pablo Galindo2021-04-121-588/+1148
| | | | | | | | | | | | | * bpo-43797: Improve syntax error for invalid comparisons * Update Lib/test/test_fstring.py Co-authored-by: Guido van Rossum <gvanrossum@gmail.com> * Apply review comments * can't -> cannot Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
* bpo-43798: Add source location attributes to alias (GH-25324)Matthew Suozzo2021-04-101-3/+57
| | | | | | | * Add source location attributes to alias. * Move alias star construction to pegen helper. Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-43244: Rename pycore_ast.h functions to _PyAST_xxx() (GH-25252)Victor Stinner2021-04-071-147/+147
| | | | | | Rename AST functions of pycore_ast.h to use the "_PyAST_" prefix. Remove macros creating aliases without prefix. For example, Module() becomes _PyAST_Module(). Update Grammar/python.gram to use _PyAST_xxx() functions.
* bpo-41064: Improve syntax error for invalid usage of '**' in f-strings ↵Pablo Galindo2021-03-241-1/+34
| | | | (GH-25006)
* bpo-43244: Fix test_peg_generators on Windows (GH-24913)Victor Stinner2021-03-181-3/+2
| | | | Don't redefine Py_DebugFlag, it's already defined in pydebug.h which is included by Python.h
* bpo-42128: Add 'missing :' syntax error message to match statements (GH-24733)Pablo Galindo2021-03-181-184/+324
|
* bpo-11717: fix ssize_t redefinition error when targeting 32bit Windows app ↵Jozef Grajciar2021-03-011-172/+172
| | | | (GH-24479)
* bpo-42128: Structural Pattern Matching (PEP 634) (GH-22917)Brandt Bucher2021-02-261-1268/+4597
| | | | | Co-authored-by: Guido van Rossum <guido@python.org> Co-authored-by: Talin <viridia@gmail.com> Co-authored-by: Pablo Galindo <pablogsal@gmail.com>