summaryrefslogtreecommitdiffstats
path: root/Parser
Commit message (Collapse)AuthorAgeFilesLines
* bpo-43833: Emit warnings for numeric literals followed by keyword (GH-25466)Serhiy Storchaka2021-06-081-0/+128
| | | | | | | | Emit a deprecation warning if the numeric literal is immediately followed by one of keywords: and, else, for, if, in, is, or. Raise a syntax error with more informative message if it is immediately followed by other keyword or identifier. Automerge-Triggered-By: GH:pablogsal
* bpo-44335: Ensure the tokenizer doesn't go into Python with the error set ↵Pablo Galindo2021-06-081-3/+17
| | | | (GH-26608)
* bpo-44335: Fix a regression when identifying invalid characters in syntax ↵Pablo Galindo2021-06-081-1/+3
| | | | errors (GH-26589)
* fix: use unambiguous punction in 'invalid escape sequence' message (GH-26582)Ned Batchelder2021-06-081-2/+2
|
* bpo-44305: Improve syntax error for try blocks without except or finally ↵Pablo Galindo2021-06-031-269/+358
| | | | (GH-26523)
* bpo-11105: Do not crash when compiling recursive ASTs (GH-20594)Batuhan Taskaya2021-06-031-4/+15
| | | | | | | When compiling an AST object with a direct / indirect reference cycles, on the conversion phase because of exceeding amount of calls, a segfault was raised. This patch adds recursion guards to places for preventing user inputs to not to crash AST but instead raise a RecursionError.
* bpo-44273: Improve syntax error message for assigning to "..." (GH-26477)Serhiy Storchaka2021-06-011-1/+1
| | | Use "ellipsis" instead of "Ellipsis" in syntax error messages to eliminate confusion with built-in variable Ellipsis.
* bpo-44201: Avoid side effects of "invalid_*" rules in the REPL (GH-26298)Pablo Galindo2021-05-223-0/+22
| | | | | | | | | | | | When the parser does a second pass to check for errors, these rules can have some small side-effects as they may advance the parser more than the point reached in the first pass. This can cause the tokenizer to ask for extra tokens in interactive mode causing the tokenizer to show the prompt instead of failing instantly. To avoid this, add a new mode to the tokenizer that is activated in the second pass and deactivates asking for new tokens when the interactive line is finished. As the parsing should have reached the last line in the first pass, the second pass should not need to ask for more tokens.
* bpo-44180: Fix edge cases in invalid assigment rules in the parser (GH-26283)Pablo Galindo2021-05-213-1172/+1403
| | | | | | | | | | | | | | | 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.
* bpo-44180: Report generic syntax errors in the furthest position reached in ↵Pablo Galindo2021-05-211-1/+6
| | | | the first parser pass (GH-26253)
* bpo-44168: Fix error message in the parser for keyword arguments for invalid ↵Pablo Galindo2021-05-191-541/+584
| | | | expressions (GH-26210)
* bpo-44143: Fix crash in the parser when raising tokenizer errors with an ↵Pablo Galindo2021-05-151-0/+1
| | | | exception set (GH-26144)
* bpo-43149: Correct the syntax error message for multiple exception types ↵Pablo Galindo2021-05-081-1/+1
| | | | | (GH-25996) Automerge-Triggered-By: GH:pablogsal
* bpo-43822: Prioritize tokenizer errors over custom syntax errors when ↵Pablo Galindo2021-05-041-0/+3
| | | | raising parser exceptions (GH-25866)
* bpo-43892: Validate the first term of complex literal value patterns (GH-25735)Brandt Bucher2021-04-303-397/+526
|
* bpo-43892: Make match patterns explicit in the AST (GH-25585)Nick Coghlan2021-04-294-745/+1352
| | | Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
* bpo-30555: Fix WindowsConsoleIO fails in the presence of fd redirection ↵Segev Finer2021-04-231-4/+2
| | | | | | | | (GH-1927) This works by not caching the handle and instead getting the handle from the file descriptor each time, so that if the actual handle changes by fd redirection closing/opening the console handle beneath our feet, we will keep working correctly.
* bpo-43914: Highlight invalid ranges in SyntaxErrors (#25525)Pablo Galindo2021-04-233-471/+596
| | | | | | | | | | | | | | | | | 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-154-637/+796
|
* 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-122-592/+1152
| | | | | | | | | | | | | * 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-104-7/+62
| | | | | | | * 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>
* Simplify _PyPegen_fill_token in pegen.c (GH-25295)Pablo Galindo2021-04-091-58/+64
|
* Sanitize macros and debug functions in pegen.c (GH-25291)Pablo Galindo2021-04-092-3/+10
|
* Break down some complex functions in pegen.c for readability (GH-25292)Pablo Galindo2021-04-081-79/+91
|
* Fix possible refleak involving _PyArena_AddPyObject (GH-25289)Erlend Egeberg Aasland2021-04-081-1/+4
|
* bpo-43244: Rename pycore_ast.h functions to _PyAST_xxx() (GH-25252)Victor Stinner2021-04-074-210/+211
| | | | | | 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-43244: Remove Yield macro from pycore_ast.h (GH-25243)Victor Stinner2021-04-071-36/+31
| | | | | | | | * pycore_ast.h no longer defines the Yield macro. * Fix a compiler warning on Windows: "warning C4005: 'Yield': macro redefinition". * Python-ast.c now defines directly functions with their real _Py_xxx() name, rather than xxx(). * Remove "#undef Yield" in C files including pycore_ast.h.
* bpo-43651: PEP 597: Fix EncodingWarning in some tests (GH-25142)Inada Naoki2021-04-021-1/+1
| | | | | | | | | | | | | * test__xxsubinterpreters * test_builtin * test_doctest * test_exceptions * test_opcodes * test_support * test_argparse * test_baseexception * test_bdb * test_bool * test_asdl_parser
* Fix tokenizer error when raw decoding null bytes (GH-25080)Pablo Galindo2021-03-291-1/+4
|
* bpo-25643: Refactor the C tokenizer into smaller, logical units (GH-25050)Pablo Galindo2021-03-282-357/+334
|
* bpo-41064: Improve syntax error for invalid usage of '**' in f-strings ↵Pablo Galindo2021-03-241-1/+34
| | | | (GH-25006)
* bpo-43244: Remove the pyarena.h header (GH-25007)Victor Stinner2021-03-243-19/+19
| | | | | | | | | | | | | | | | | | Remove the pyarena.h header file with functions: * PyArena_New() * PyArena_Free() * PyArena_Malloc() * PyArena_AddPyObject() These functions were undocumented, excluded from the limited C API, and were only used internally by the compiler. Add pycore_pyarena.h header. Rename functions: * PyArena_New() => _PyArena_New() * PyArena_Free() => _PyArena_Free() * PyArena_Malloc() => _PyArena_Malloc() * PyArena_AddPyObject() => _PyArena_AddPyObject()
* bpo-43244: Remove parser_interface.h header file (GH-25001)Victor Stinner2021-03-243-64/+5
| | | | | | | | | | | | | | | | | | | | | | | | | Remove parser functions using the "struct _mod" type, because the AST C API was removed: * PyParser_ASTFromFile() * PyParser_ASTFromFileObject() * PyParser_ASTFromFilename() * PyParser_ASTFromString() * PyParser_ASTFromStringObject() These functions were undocumented and excluded from the limited C API. Add pycore_parser.h internal header file. Rename functions: * PyParser_ASTFromFileObject() => _PyParser_ASTFromFile() * PyParser_ASTFromStringObject() => _PyParser_ASTFromString() These functions are no longer exported (replace PyAPI_FUNC() with extern). Remove also _PyPegen_run_parser_from_file() function. Update test_peg_generator to use _PyPegen_run_parser_from_file_pointer() instead.
* bpo-43244: Remove ast.h, asdl.h, Python-ast.h headers (GH-24933)Victor Stinner2021-03-234-32/+46
| | | | | | | | | | | | | | | | These functions were undocumented and excluded from the limited C API. Most names defined by these header files were not prefixed by "Py" and so could create names conflicts. For example, Python-ast.h defined a "Yield" macro which was conflict with the "Yield" name used by the Windows <winbase.h> header. Use the Python ast module instead. * Move Include/asdl.h to Include/internal/pycore_asdl.h. * Move Include/Python-ast.h to Include/internal/pycore_ast.h. * Remove ast.h header file. * pycore_symtable.h no longer includes Python-ast.h.
* bpo-43555: Report the column offset for invalid line continuation character ↵Pablo Galindo2021-03-222-6/+6
| | | | (GH-24939)
* bpo-43591: Fix error location in interactive mode for errors at the end of ↵Pablo Galindo2021-03-221-5/+9
| | | | | the line (GH-24973) Co-authored-by: Erlend Egeberg Aasland
* bpo-43244: Remove the PyAST_Validate() function (GH-24911)Victor Stinner2021-03-181-1/+2
| | | | | | | | | | | | Remove the PyAST_Validate() function. It is no longer possible to build a AST object (mod_ty type) with the public C API. The function was already excluded from the limited C API (PEP 384). Rename PyAST_Validate() function to _PyAST_Validate(), move it to the internal C API, and don't export it anymore (replace PyAPI_FUNC with extern). The function was added in bpo-12575 by the commit 832bfe2ebd5ecfa92031cd40c8b41835ba90487f.
* 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-43244: Fix test_peg_generator for PyAST_Validate() (GH-24912)Victor Stinner2021-03-182-31/+6
| | | | | | | | | test_peg_generator now defines _Py_TEST_PEGEN macro when building C code to not call PyAST_Validate() in Parser/pegen.c. Moreover, it defines Py_BUILD_CORE_MODULE macro to get access to the internal C API. Remove "global_ast_state" from Python-ast.c when it's built by test_peg_generator: always get the AST state from the current interpreter.
* bpo-42128: Add 'missing :' syntax error message to match statements (GH-24733)Pablo Galindo2021-03-181-184/+324
|
* bpo-43244: Rename pycore_ast.h to pycore_ast_state.h (GH-24907)Victor Stinner2021-03-171-4/+4
|
* bpo-43410: Fix crash in the parser when producing syntax errors when reading ↵Pablo Galindo2021-03-143-30/+66
| | | | from stdin (GH-24763)
* 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-263-1269/+4609
| | | | | Co-authored-by: Guido van Rossum <guido@python.org> Co-authored-by: Talin <viridia@gmail.com> Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* bpo-35134: Move non-limited C API files to Include/cpython/ (GH-24561)Nicholas Sim2021-02-191-1/+1
| | | | | | Include/{odictobject.h,parser_interface.h,picklebufobject.h,pydebug.h,pyfpe.h} into Include/cpython/. Parser: peg_api: include Python.h instead of parser_interface.h.