191 Commits

Author SHA1 Message Date
Stan Ulbrych 87fac9b8ee [3.14] gh-145783: Propagate errors raised in NEW_TYPE_COMMENT (GH-145784) (#145926) 2026-03-13 18:08:04 +00:00
Brian Schubert d0c78a458b [3.14] gh-138944: Fix SyntaxError message for invalid syntax following valid import-as statement (GH-138945) (#140646)
(cherry picked from commit 3dab11f888)
2025-10-31 11:26:40 +01:00
Miss Islington (bot) 7b56d08219 [3.14] gh-137078: Fix keyword typo recognition when executed over files (GH-137079) (#137826) 2025-08-15 18:22:17 +01:00
Lysandros Nikolaou af8d1f56f5 [3.14] gh-132661: Disallow Template/str concatenation after PEP 750 spec update (#135996) (#136901)
Co-authored-by: Dave Peck <davepeck@gmail.com>
Co-authored-by: sobolevn <mail@sobolevn.me>
2025-07-21 17:34:54 +02:00
Miss Islington (bot) 904685f90f [3.14] gh-133157: remove usage of _Py_NO_SANITIZE_UNDEFINED in Parser/pegen.c (GH-134048) (#135320)
gh-133157: remove usage of `_Py_NO_SANITIZE_UNDEFINED` in `Parser/pegen.c` (GH-134048)
(cherry picked from commit 754e7c9b51)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-06-10 00:34:49 +00:00
Miss Islington (bot) 89df01bd27 [3.14] gh-135028: Increase parser MAXSTACK for nested parenthesis (GH-135031) (#135059)
gh-135028: Increase parser MAXSTACK for nested parenthesis (GH-135031)
(cherry picked from commit 6e80f11eb5)

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-06-03 12:23:06 +00:00
Miss Islington (bot) d9c08c57e9 [3.14] gh-133999: Fix except parsing regression in 3.14 (GH-134035) (#134206)
gh-133999: Fix `except` parsing regression in 3.14 (GH-134035)
(cherry picked from commit 84914ad0e5)

Co-authored-by: sobolevn <mail@sobolevn.me>
2025-05-19 14:26:27 +03:00
sobolevn ca0a96dfaa gh-133194: Fix regression with PEP 758 parsing on older feature_version (#133289)
gh-133192: Fix regression with PEP 758 parsing on older `feature_version`
2025-05-03 10:33:14 +03:00
sobolevn a6ddd078d0 gh-123539: Improve SyntaxError msg for import as with not a name (#123629) 2025-05-02 08:34:13 +00:00
sobolevn 5cdd49b3f4 gh-133196: Guard PEP 750 grammar with CHECK_VERSION (#133225) 2025-05-01 09:17:07 +02:00
sobolevn b1f893875b gh-133194: Add CHECK_VERSION to new PEP758 grammar (#133195) 2025-04-30 13:39:26 +03:00
Lysandros Nikolaou 60202609a2 gh-132661: Implement PEP 750 (#132662)
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Wingy <git@wingysam.xyz>
Co-authored-by: Koudai Aono <koxudaxi@gmail.com>
Co-authored-by: Dave Peck <davepeck@gmail.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Paul Everitt <pauleveritt@me.com>
Co-authored-by: sobolevn <mail@sobolevn.me>
2025-04-30 11:46:41 +02:00
Steele Farnsworth 99b71efe8e gh-129858: Special syntax error for elif block after else (#129902) 2025-04-25 01:25:48 +00:00
Pablo Galindo Salgado bf3a0a1c0f gh-132449: Improve syntax error messages for keywords with typos (#132450)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-04-22 11:01:55 +02:00
Pablo Galindo Salgado c2ac662f28 gh-131831: Implement PEP 758 – Allow except and except* expressions without parentheses (#131833) 2025-04-01 19:04:56 +00:00
Mark Shannon 014223649c GH-130396: Use computed stack limits on linux (GH-130398)
* Implement C recursion protection with limit pointers for Linux, MacOS and Windows

* Remove calls to PyOS_CheckStack

* Add stack protection to parser

* Make tests more robust to low stacks

* Improve error messages for stack overflow
2025-02-25 09:24:48 +00:00
Petr Viktorin ef29104f7d GH-91079: Revert "GH-91079: Implement C stack limits using addresses, not counters. (GH-130007)" for now (GH130413)
Revert "GH-91079: Implement C stack limits using addresses, not counters. (GH-130007)" for now

Unfortunatlely, the change broke some buildbots.

This reverts commit 2498c22fa0.
2025-02-24 11:16:08 +01:00
Mark Shannon 2498c22fa0 GH-91079: Implement C stack limits using addresses, not counters. (GH-130007)
* Implement C recursion protection with limit pointers

* Remove calls to PyOS_CheckStack

* Add stack protection to parser

* Make tests more robust to low stacks

* Improve error messages for stack overflow
2025-02-19 11:44:57 +00:00
Sergey Miryanov bcc9a5dddb gh-129515: Clarify syntax error messages for conditional expressions (#129880)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-02-18 21:43:19 +00:00
Pablo Galindo Salgado 3bd3e09588 gh-125331: Allow the parser to activate future imports on the fly (#125482) 2025-02-14 04:54:56 +00:00
Pablo Galindo Salgado 6fb5138776 gh-88535: Improve syntax error for wrongly closed strings (#26633) 2025-02-13 01:30:20 +00:00
Rigel Di Scala 39c859f6ff gh-122951: Simplify the grammar of the assignment rule (#124998) 2024-10-06 11:55:56 +02:00
efimov-mikhail 1f9025a4e7 gh-124889: Remove redundant artificial rules in PEG parser (#124893)
Cache in C PEG-generator reworked:
we save artificial rules in cache by Node string representation as a key instead of Node object itself.
As a result total count of artificial rules in parsers.c is lowered from 283 to 170.
More natural number ordering is used for the names of artificial rules.

Auxiliary method CCallMakerVisitor._generate_artificial_rule_call is added.
Its purpose is abstracting work with artificial rules cache.

Explicit using of "is_repeat1" kwarg is added to visit_Repeat0 and visit_Repeat1 methods.
Its slightly improve code readabitily.
2024-10-03 13:58:56 +01:00
sobolevn 23f159ae71 gh-123562: Improve SyntaxError message for case ... as a.b (#123563) 2024-09-02 13:11:44 +02:00
sobolevn e451a8937d gh-123440: Improve error message for except as used with not a name (#123442) 2024-08-30 17:21:59 +01:00
Lysandros Nikolaou 348184845a gh-120956: Avoid comparison of int to Py_ssize_t in parser (#120959) 2024-06-24 18:13:02 +02:00
Petr Viktorin 31a4fb3c74 gh-119724: Revert "bpo-45759: Better error messages for non-matching 'elif'/'else' statements (#29513)" (#119974)
This reverts commit 1c8f912ebd.
2024-06-03 18:10:15 -07:00
Petr Viktorin 48f21b3631 gh-118235: Move RAISE_SYNTAX_ERROR actions to invalid rules and make sure they stay there (GH-119731)
The Full Grammar specification in the docs omits rule actions, so grammar rules that raise a syntax error looked like valid syntax.
This was solved in ef940de by hiding those rules in the custom syntax highlighter.

This moves all syntax-error alternatives to invalid rules, adds a validator that ensures that actions containing RAISE_SYNTAX_ERROR are in invalid rules, and reverts the syntax highlighter hack.
2024-05-30 09:27:32 +02:00
Nikita Sobolev b60d4c0d53 gh-118090: Improve error message for empty type param brackets (GH-118091) 2024-05-07 14:01:06 +02:00
Jelle Zijlstra ca269e58c2 gh-116126: Implement PEP 696 (#116129)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2024-05-03 06:17:32 -07:00
David Rubin 9b280ab0ab gh-116988: Remove duplicates of annotated_rhs in the Grammar (#117004) 2024-04-24 18:16:06 +01:00
Nikita Sobolev de1f686827 gh-118082: Improve import without names syntax error message (#118083) 2024-04-23 13:00:52 +01:00
Grigoriev Semyon c97d3af239 gh-109120: Fix syntax error in handlinh of incorrect star expressions (#117444) 2024-04-02 11:42:58 +01:00
Pablo Galindo Salgado 61599a48f5 bpo-24612: Improve syntax error for 'not' after an operator (GH-28170)
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
2024-03-26 10:30:46 +01:00
Alex Waygood 7a3518e43a gh-115881: Ensure ast.parse() parses conditional context managers even with low feature_version passed (#115920) 2024-02-26 09:22:09 +00:00
Grigoriev Semyon bb4c167060 gh-111488: Changed error message in case of no 'in' keyword after 'for' in cmp (#113656) 2024-01-06 10:27:49 +00:00
Crowthebird 1c8f912ebd bpo-45759: Better error messages for non-matching 'elif'/'else' statements (#29513) 2023-11-20 13:27:53 +00:00
Brett Cannon 56e59a49ae GH-111807: Lower the parser stack depth under WASI debug builds (#112225) 2023-11-20 13:27:33 +00:00
Tomas R 453e96e302 gh-111420: Allow type comments in parenthesized with statements (#111468) 2023-10-31 21:02:42 +00:00
Pablo Galindo Salgado 24e4ec7766 gh-110938: Fix error messages for indented blocks with functions and classes with generic type parameters (#110973) 2023-10-17 13:45:13 +01:00
Pablo Galindo Salgado 3d180347ae gh-110696: Fix incorrect syntax error message for incorrect argument unpacking (#110706) 2023-10-12 09:02:02 +00:00
Pablo Galindo Salgado b28ffaa193 gh-109596: Ensure repeated rules in the grammar are not allowed and fix incorrect soft keywords (#109606) 2023-09-22 19:03:23 +01:00
Pablo Galindo Salgado 5bda2f637e gh-109114: Relax the check for invalid lambdas inside f-strings to avoid false positives (#109121) 2023-09-08 17:00:23 +00:00
Dennis Sweeney 86617518c4 gh-108179: Add error message for parser stack overflows (#108256) 2023-08-22 08:41:50 +01:00
Pablo Galindo Salgado da8f87b7ea gh-107015: Remove async_hacks from the tokenizer (#107018) 2023-07-26 16:34:15 +01:00
Pablo Galindo Salgado 13237a2da8 gh-98931: Add custom error messages to invalid import/from with multiple targets (#105985)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-06-22 15:56:40 +00:00
Pablo Galindo Salgado 41de54378d gh-105194: Fix format specifier escaped characters in f-strings (#105231) 2023-06-02 13:33:26 +02:00
Jelle Zijlstra ba73473f4c gh-104799: Move location of type_params AST fields (#104828)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-05-26 05:54:37 -07:00
Jelle Zijlstra a5f244d627 gh-104656: Rename typeparams AST node to type_params (#104657) 2023-05-21 21:25:09 -07:00
Jelle Zijlstra 24d8b88420 gh-103763: Implement PEP 695 (#103764)
This implements PEP 695, Type Parameter Syntax. It adds support for:

- Generic functions (def func[T](): ...)
- Generic classes (class X[T](): ...)
- Type aliases (type X = ...)
- New scoping when the new syntax is used within a class body
- Compiler and interpreter changes to support the new syntax and scoping rules 

Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: Eric Traut <eric@traut.com>
Co-authored-by: Larry Hastings <larry@hastings.org>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-05-15 20:36:23 -07:00