summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_syntax.py
Commit message (Collapse)AuthorAgeFilesLines
* [3.9] bpo-39934: Account for control blocks in 'except' in compiler. ↵Irit Katriel2020-11-171-0/+9
| | | | | (GH-22395) (GH-23303) * bpo-39934: backport PR 22395 to 3.9
* [3.9] bpo-42218: Correctly handle errors in left-recursive rules (GH-23065) ↵Lysandros Nikolaou2020-10-311-0/+8
| | | | | | | | | | | | (GH-23066) 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> (cherry picked from commit 02cdfc93f82fecdb7eae97a868d4ee222b9875d9) Automerge-Triggered-By: GH:lysnikolaou
* [3.9] bpo-42214: Fix check for NOTEQUAL token in the PEG parser for the ↵Pablo Galindo2020-10-311-0/+17
| | | | | | | barry_as_flufl rule (GH-23048) (GH-23051) (cherry picked from commit 06f8c3328dcd81c84d1ee2b3a57b5381dcb38482) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* [3.9] bpo-41659: Disallow curly brace directly after primary (GH-22996) (#23006)Lysandros Nikolaou2020-10-271-0/+3
| | | (cherry picked from commit 15acc4eaba8519d7d5f2acaffde65446b44dcf79)
* [3.9] bpo-40769: Allow extra surrounding parentheses for invalid annotated ↵Pablo Galindo2020-06-271-0/+13
| | | | | assignment rule (GH-20387) (GH-21186) (cherry picked from commit c8f29ad986f8274fc5fbf889bdd2a211878856b9)
* [3.9] bpo-41060: Avoid SEGFAULT when calling GET_INVALID_TARGET in the ↵Lysandros Nikolaou2020-06-211-0/+8
| | | | | | | | | | | | | grammar (GH-21020) (GH-21024) `GET_INVALID_TARGET` might unexpectedly return `NULL`, which if not caught will cause a SEGFAULT. Therefore, this commit introduces a new inline function `RAISE_SYNTAX_ERROR_INVALID_TARGET` that always checks for `GET_INVALID_TARGET` returning NULL and can be used in the grammar, replacing the long C ternary operation used till now. (cherry picked from commit 6c4e0bd974f2895d42b63d9d004587e74b286c88) Automerge-Triggered-By: @pablogsal
* [3.9] bpo-40334: Produce better error messages on invalid targets (GH-20106) ↵Lysandros Nikolaou2020-06-191-1/+56
| | | | | | | | | | | | | | | | | | | (GH-20973) * bpo-40334: Produce better error messages on invalid targets (GH-20106) The following error messages get produced: - `cannot delete ...` for invalid `del` targets - `... is an illegal 'for' target` for invalid targets in for statements - `... is an illegal 'with' target` for invalid targets in with statements Additionally, a few `cut`s were added in various places before the invocation of the `invalid_*` rule, in order to speed things up. Co-authored-by: Pablo Galindo <Pablogsal@gmail.com> (cherry picked from commit 01ece63d42b830df106948db0aefa6c1ba24416a)
* bpo-40847: Consider a line with only a LINECONT a blank line (GH-20769)Miss Islington (bot)2020-06-111-0/+14
| | | | | | | | | | | | | A line with only a line continuation character should be considered a blank line at tokenizer level so that only a single NEWLINE token gets emitted. The old parser was working around the issue, but the new parser threw a `SyntaxError` for valid input. For example, an empty line following a line continuation character was interpreted as a `SyntaxError`. Co-authored-by: Pablo Galindo <Pablogsal@gmail.com> (cherry picked from commit 896f4cf63f9ab93e30572d879a5719d5aa2499fb) Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
* [3.9] Remove PEG-specific syntax error check in the old parser (GH-20717)Pablo Galindo2020-06-081-4/+0
|
* bpo-40903: Handle multiple '=' in invalid assignment rules in the PEG parser ↵Miss Islington (bot)2020-06-081-1/+20
| | | | | | | | (GH-20697) Automerge-Triggered-By: @pablogsal (cherry picked from commit 9f495908c5bd3645ed1af82d7bae6782720dab77) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-40334: Produce better error messages for non-parenthesized genexps ↵Miss Islington (bot)2020-05-221-5/+3
| | | | | | | | | (GH-20153) The error message, generated for a non-parenthesized generator expression in function calls, was still the generic `invalid syntax`, when the generator expression wasn't appearing as the first argument in the call. With this patch, even on input like `f(a, b, c for c in d, e)`, the correct error message gets produced. (cherry picked from commit ae145833025b0156ee2a28219e3370f3b27b2a36) Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
* [3.9] bpo-40176: Improve error messages for trailing comma on from import ↵Pablo Galindo2020-05-211-0/+8
| | | | | | | (GH-20294) (GH-20302) (cherry picked from commit 72e0aa2) Co-authored-by: Batuhan Taskaya <batuhanosmantaskaya@gmail.com>
* bpo-40334: Reproduce error message for type comments on bare '*' in the new ↵Lysandros Nikolaou2020-05-181-0/+10
| | | | parser (GH-20151)
* bpo-40661: Fix segfault when parsing invalid input (GH-20165)Lysandros Nikolaou2020-05-181-0/+3
| | | | | | Fix segfaults when parsing very complex invalid input, like `import äˆ ð£„¯ð¢·žð±‹á”€ð””ð‘©±å®ä±¬ð©¾\n𗶽`. Co-authored-by: Guido van Rossum <guido@python.org> Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* bpo-40334: Correctly identify invalid target in assignment errors (GH-20076)Pablo Galindo2020-05-151-19/+27
| | | Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
* bpo-40618: Disallow invalid targets in augassign and except clauses (GH-20083)Lysandros Nikolaou2020-05-141-0/+12
| | | | | | | | | This commit fixes the new parser to disallow invalid targets in the following scenarios: - Augmented assignments must only accept a single target (Name, Attribute or Subscript), but no tuples or lists. - `except` clauses should only accept a single `Name` as a target. Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-40334: produce specialized errors for invalid del targets (GH-19911)Shantanu2020-05-111-8/+33
|
* bpo-40334: Spacialized error message for invalid args after bare '*' (GH-19865)Lysandros Nikolaou2020-05-041-3/+3
| | | When parsing things like `def f(*): pass` the old parser used to output `SyntaxError: named arguments must follow bare *`, which the new parser wasn't able to do.
* bpo-40443: Remove unused imports in tests (GH-19805)Victor Stinner2020-04-291-1/+0
|
* bpo-40334: Rename PyConfig.use_peg to _use_peg_parser (GH-19670)Victor Stinner2020-04-231-2/+2
| | | | | | | | | | | * Rename PyConfig.use_peg to _use_peg_parser * Document PyConfig._use_peg_parser and mark it a deprecated * Mark -X oldparser option and PYTHONOLDPARSER env var as deprecated in the documentation. * Add use_old_parser() and skip_if_new_parser() to test.support * Remove sys.flags.use_peg: use_old_parser() uses _testinternalcapi.get_configs() instead. * Enhance test_embed tests * subprocess._args_from_interpreter_flags() copies -X oldparser
* bpo-40334: PEP 617 implementation: New PEG parser for CPython (GH-19503)Pablo Galindo2020-04-221-39/+49
| | | | Co-authored-by: Guido van Rossum <guido@python.org> Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
* bpo-40147: Move the check for duplicate keywords to the compiler (GH-19289)Pablo Galindo2020-04-031-1/+1
|
* bpo-39176: Improve error message for 'named assignment' (GH-17777)Ned Batchelder2020-01-011-1/+1
|
* bpo-37500: Make sure dead code does not generate bytecode but also detect ↵Pablo Galindo2019-07-151-6/+35
| | | | | | | | | | | | syntax errors (GH-14612) https://bugs.python.org/issue37500 Add a new field to the compiler structure that allows to be configured so no bytecode is emitted. In this way is possible to detect errors by walking the nodes while preserving optimizations. https://bugs.python.org/issue37500
* bpo-1875: Raise SyntaxError in invalid blocks that will be optimised away ↵Pablo Galindo2019-05-171-0/+14
| | | | | | | (GH-13332) Move the check for dead conditionals (if 0) to the peephole optimizer and make sure that the code block is still compiled to report any existing syntax errors within.
* bpo-36187: Remove NamedStore. (GH-12167)Serhiy Storchaka2019-03-051-0/+4
| | | | | NamedStore has been replaced with Store. The difference between NamedStore and Store is handled when precess the NamedExpr node one level upper.
* bpo-36052: Raise a SyntaxError when assigning a value to __debug__ with := ↵Stéphane Wirtel2019-02-211-0/+4
| | | | | | | (GH-11958) Trying to assign a value to __debug__ using the assignment operator is supposed to fail, but a missing check for forbidden names when setting the context in the ast was preventing this behaviour.
* bpo-35169: Improve error messages for forbidden assignments. (GH-10342)Serhiy Storchaka2018-11-201-30/+87
|
* closes bpo-34641: Further restrict the LHS of keyword argument function call ↵Benjamin Peterson2018-09-131-0/+3
| | | | syntax. (GH-9212)
* bpo-32489: Allow 'continue' in 'finally' clause. (GH-5822)Serhiy Storchaka2018-03-181-45/+23
|
* bpo-32482: Fix suspicious code in tests for syntax and grammar. (#5086)Serhiy Storchaka2018-01-041-2/+2
|
* bpo-32023: Disallow genexprs without parenthesis in class definitions. (#4400)Serhiy Storchaka2017-11-151-0/+4
|
* bpo-32012: Disallow trailing comma after genexpr without parenthesis. (#4382)Serhiy Storchaka2017-11-151-3/+18
|
* bpo-28936: Detect lexically first syntax error first (#4097)Ivan Levkivskyi2017-10-261-9/+27
| | | | Lexically first global and nonlocal syntax errors at given scope should be detected first.
* bpo-31847: Fix commented out tests in test_syntax. (#4084)Serhiy Storchaka2017-10-231-18/+10
| | | SyntaxError now is raised instead of SyntaxWarning.
* Issue #26110: Add LOAD_METHOD/CALL_METHOD opcodes.Yury Selivanov2016-12-141-0/+27
| | | | | | | Special thanks to INADA Naoki for pushing the patch through the last mile, Serhiy Storchaka for reviewing the code, and to Victor Stinner for suggesting the idea (originally implemented in the PyPy project).
* Issue #28512: Fixed setting the offset attribute of SyntaxError bySerhiy Storchaka2016-12-111-2/+7
|\ | | | | | | PyErr_SyntaxLocationEx() and PyErr_SyntaxLocationObject().
| * Issue #28512: Fixed setting the offset attribute of SyntaxError bySerhiy Storchaka2016-12-111-2/+7
| |\ | | | | | | | | | PyErr_SyntaxLocationEx() and PyErr_SyntaxLocationObject().
| | * Issue #28512: Fixed setting the offset attribute of SyntaxError bySerhiy Storchaka2016-12-111-3/+8
| | | | | | | | | | | | PyErr_SyntaxLocationEx() and PyErr_SyntaxLocationObject().
* | | Issue #12844: More than 255 arguments can now be passed to a function.Serhiy Storchaka2016-11-281-63/+67
|/ /
* | Issue #27999: Make "global after use" a SyntaxError, and ditto for nonlocal.Guido van Rossum2016-09-091-1/+17
| | | | | | | | Patch by Ivan Levkivskyi.
* | merge 3.5 (#27514)Benjamin Peterson2016-07-151-2/+4
|\ \ | |/
| * make too many nested blocks be a SyntaxError instead of a SystemError ↵Benjamin Peterson2016-07-151-2/+4
| | | | | | | | | | | | (closes #27514) Patch by Ammar Askar.
* | Issue #23275: Allow () = iterable assignment syntaxBerker Peksag2016-05-181-12/+0
|/ | | | Documentation updates by Martin Panter.
* make recording and reporting errors and nonlocal and global directives more ↵Benjamin Peterson2015-12-291-0/+8
| | | | robust (closes #25973)
* PEP 448: additional unpacking generalizations (closes #2292)Benjamin Peterson2015-05-061-1/+15
| | | | Patch by Neil Girdhar.
* create NameConstant AST class for None, True, and False literals (closes #16619)Benjamin Peterson2012-12-061-2/+2
|
* merge 3.1Benjamin Peterson2011-04-121-0/+4
|\
| * make assigning to a bytes literal a syntax error (closes #11506)Benjamin Peterson2011-04-121-0/+4
| |
* | #11565: Merge with 3.1.Ezio Melotti2011-03-161-1/+1
|\ \ | |/