summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_syntax.py
Commit message (Collapse)AuthorAgeFilesLines
* [3.10] gh-101400: Fix incorrect lineno in exception message on contin… ↵Dong-hee Na2023-01-311-13/+17
| | | | (gh-101448)
* [3.10] gh-100050: Fix an assertion error when raising unclosed parenthesis ↵Pablo Galindo Salgado2022-12-071-0/+16
| | | | | | | | errors in the tokenizer (GH-100065) (#100073) Automerge-Triggered-By: GH:pablogsal. (cherry picked from commit 97e7004cfe48305bcd642c653b406dc7470e196d) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* [3.10] gh-94192: Fix error for dictionary literals with invalid expression ↵wookie1842022-06-271-3/+13
| | | | | 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-10/+31
| | | | | | | | | 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] Backport bpo-47212 (GH-32302) to Python 3.10 (GH-32334)Matthieu Dartiailh2022-04-051-0/+7
| | | | | | | | | (cherry picked from commit aa0f056a00c4bcaef83d729e042359ddae903382) # Conflicts: # Grammar/python.gram # Parser/action_helpers.c Automerge-Triggered-By: GH:pablogsal
* [3.10] bpo-46707: Avoid potential exponential backtracking in some syntax ↵Pablo Galindo Salgado2022-02-101-0/+8
| | | | | | | errors (GH-31241). (GH-31242) (cherry picked from commit b71dc71905ab674ccaa4a56230d17a28f61c325c) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* [3.10] bpo-46091: Correctly calculate indentation levels for whitespace ↵Pablo Galindo Salgado2022-01-251-0/+30
| | | | | | | lines with continuation characters (GH-30130). (GH-30898) (cherry picked from commit a0efc0c1960e2c49e0092694d98395555270914c) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* [3.10] bpo-46240: Correct the error for unclosed parentheses when the ↵Pablo Galindo Salgado2022-01-231-0/+3
| | | | | | | tokenizer is not finished (GH-30378). (GH-30819) (cherry picked from commit 70f415fb8b632247e28d87998642317ca7a652ae) 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-0/+8
| | | | | | | | 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>
* [3.10] bpo-45716: Improve the error message when using True/False/None as ↵Pablo Galindo Salgado2021-11-161-2/+8
| | | | | | | keywords in a call (GH-29413). (GH-29428) (cherry picked from commit e2d65630f36712dbdbf7711520c985c526a5cc25) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* bpo-45738: Fix computation of error location for invalid continuation (GH-29550)Miss Islington (bot)2021-11-141-1/+7
| | | | | | characters in the parser (cherry picked from commit 25835c518aa7446f3680b62c1fb43827e0f190d9) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* [3.10] Remove trailing spaces (GH-28709)Serhiy Storchaka2021-10-031-2/+2
|
* bpo-43914: Correctly highlight SyntaxError exceptions for invalid generator ↵Miss Islington (bot)2021-09-271-1/+12
| | | | | | | expression in function calls (GH-28576) (cherry picked from commit e5f13ce5b48b551c09fdd0faeafa6ecf860de51c) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* bpo-25130: Make unit-test about restricting the maximum number of nested ↵Miss Islington (bot)2021-08-281-32/+35
| | | | | | | | | | | | blocks cpython-only (GH-28002) (GH-28016) PyPy and potentially other implementations have different or no contraints on the number of blocks that can be statically nested. move the test that checks for this behaviour into a unit test and mark it as CPython-only. (cherry picked from commit eb263f9a356f5c5f21b8d5ce20bac92f31c40cad) Co-authored-by: Carl Friedrich Bolz-Tereick <cfbolz@gmx.de>
* bpo-45000: Raise SyntaxError when try to delete __debug__ (GH-27947) (GH-27957)Dong-hee Na2021-08-261-0/+4
| | | (cherry picked from commit 551da597a0996b0fb3af425f48aa5bc63ea6b963)
* bpo-44947: Refine the syntax error for trailing commas in import statements ↵Miss Islington (bot)2021-08-181-0/+7
| | | | | | | (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-0/+8
| | | | | | | | | | | 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/+12
| | | | | (cherry picked from commit 28b6dc9dd5d1ce6f8aff7e06d4ef9afdc2bc8332) Co-authored-by: Miguel Brito <5544985+miguendes@users.noreply.github.com>
* [3.10] bpo-34013: Generalize the invalid legacy statement error message ↵Pablo Galindo Salgado2021-07-271-1/+1
| | | | | | | (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-0/+24
| | | | | | | 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-0/+14
| | | | | | | (GH-26632) (GH-26792) (cherry picked from commit 05073036dcecefc00b0c3e7397601809da41e2f1) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-44368: Ensure we don't raise incorrect custom syntax errors with soft ↵Miss Islington (bot)2021-06-091-1/+19
| | | | | | | keywords (GH-26630) (cherry picked from commit 457ce60fc70f1c9290023f46fb82b6a490dff32e) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* [3.10] bpo-44305: Improve syntax error for try blocks without except or ↵Pablo Galindo2021-06-031-0/+8
| | | | | | | finally (GH-26523) (GH-26524) (cherry picked from commit b250f89bb7e05e72a4641d44b988866b919575db) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* [3.10] bpo-44273: Improve syntax error message for assigning to "..." ↵Pablo Galindo2021-06-031-1/+1
| | | | | | | | | | (GH-26477) (GH-26478) Use "ellipsis" instead of "Ellipsis" in syntax error messages to eliminate confusion with built-in variable Ellipsis. (cherry picked from commit 39dd141) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-44180: Fix edge cases in invalid assigment rules in the parser (GH-26283)Miss Islington (bot)2021-05-211-0/+20
| | | | | | | | | | | | | | | | | | 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-19/+24
| | | | | | | | | 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-5/+5
| | | | | | | | | | (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-44063: set the missing end locations on the compiler (GH-25956) (#25972)Miss Islington (bot)2021-05-071-0/+7
| | | | | (cherry picked from commit b2ec37a7224318d466e0877790ed740ce8b4867d) Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>
* bpo-43914: Highlight invalid ranges in SyntaxErrors (#25525)Pablo Galindo2021-04-231-1/+1
| | | | | | | | | | | | | | | | | 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-0/+132
|
* bpo-38605: Revert making 'from __future__ import annotations' the default ↵Pablo Galindo2021-04-211-0/+8
| | | | | | (GH-25490) This reverts commits 044a1048ca93d466965afc027b91a5a9eb9ce23c and 1be456ae9d53bb1cba2b24fc86175c282d1c2169, adapting the code to changes that happened after it.
* bpo-43822: Improve syntax errors for missing commas (GH-25377)Pablo Galindo2021-04-151-5/+19
|
* bpo-43823: Improve syntax errors for invalid dictionary literals (GH-25378)Pablo Galindo2021-04-151-0/+32
|
* bpo-43797: Handle correctly invalid assignments inside function calls and ↵Pablo Galindo2021-04-131-1/+13
| | | | generators (GH-25390)
* Ensure that early = are not matched by the parser as invalid comparisons ↵Pablo Galindo2021-04-131-0/+5
| | | | (GH-25375)
* bpo-43797: Improve syntax error for invalid comparisons (#25317)Pablo Galindo2021-04-121-48/+68
| | | | | | | | | | | | | * 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-43555: Report the column offset for invalid line continuation character ↵Pablo Galindo2021-03-221-0/+5
| | | | (GH-24939)
* bpo-42128: Add 'missing :' syntax error message to match statements (GH-24733)Pablo Galindo2021-03-181-0/+36
|
* bpo-43149: Improve error message for exception group without parentheses ↵Pablo Galindo2021-02-071-0/+33
| | | | (GH-24467)
* bpo-43121: Fix incorrect SyntaxError message for missing comma (GH-24436)Pablo Galindo2021-02-031-2/+18
|
* bpo-42997: Improve error message for missing : before suites (GH-24292)Pablo Galindo2021-02-021-3/+104
| | | | | | | | * Add to the peg generator a new directive ('&&') that allows to expect a token and hard fail the parsing if the token is not found. This allows to quickly emmit syntax errors for missing tokens. * Use the new grammar element to hard-fail if the ':' is missing before suites.
* bpo-43017: Improve error message for unparenthesised tuples in ↵Pablo Galindo2021-01-311-0/+15
| | | | comprehensions (GH24314)
* bpo-42864: Improve error messages regarding unclosed parentheses (GH-24161)Pablo Galindo2021-01-191-0/+8
|
* bpo-30858: Improve error location for expressions with assignments (GH-23753)Pablo Galindo2020-12-131-0/+7
| | | Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
* bpo-42218: Correctly handle errors in left-recursive rules (GH-23065)Lysandros Nikolaou2020-10-311-0/+8
| | | | | | | Left-recursive rules need to check for errors explicitly, since even if the rule returns NULL, the parsing might continue and lead to long-distance failures. Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-42214: Fix check for NOTEQUAL token in the PEG parser for the ↵Pablo Galindo2020-10-301-0/+17
| | | | barry_as_flufl rule (GH-23048)
* bpo-41659: Disallow curly brace directly after primary (GH-22996)Lysandros Nikolaou2020-10-271-0/+3
|
* bpo-38605: Make 'from __future__ import annotations' the default (GH-20434)Batuhan Taskaya2020-10-061-8/+0
| | | | | The hard part was making all the tests pass; there are some subtle issues here, because apparently the future import wasn't tested very thoroughly in previous Python versions. For example, `inspect.signature()` returned type objects normally (except for forward references), but strings with the future import. We changed it to try and return type objects by calling `typing.get_type_hints()`, but fall back on returning strings if that function fails (which it may do if there are future references in the annotations that require passing in a specific namespace to resolve).
* bpo-39934: Account for control blocks in 'except' in compiler. (GH-22395)Mark Shannon2020-09-251-0/+9
| | | * Account for control blocks in 'except' in compiler. Fixes #39934.
* bpo-40769: Allow extra surrounding parentheses for invalid annotated ↵Batuhan Taskaya2020-06-271-0/+13
| | | | assignment rule (GH-20387)