| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
| |
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
|
|
|
|
| |
(GH-26608)
|
|
|
|
| |
errors (GH-26589)
|
| |
|
|
|
|
| |
(GH-26523)
|
|
|
|
|
|
|
| |
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.
|
|
|
| |
Use "ellipsis" instead of "Ellipsis" in syntax error messages to eliminate confusion with built-in variable Ellipsis.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
the first parser pass (GH-26253)
|
|
|
|
| |
expressions (GH-26210)
|
|
|
|
| |
exception set (GH-26144)
|
|
|
|
|
| |
(GH-25996)
Automerge-Triggered-By: GH:pablogsal
|
|
|
|
| |
raising parser exceptions (GH-25866)
|
| |
|
|
|
| |
Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
|
|
|
|
|
|
|
|
| |
(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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
| |
(GH-25427)
|
| |
|
| |
|
|
|
|
| |
generators (GH-25390)
|
|
|
|
| |
(GH-25375)
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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>
|
|
|
|
|
|
|
| |
* 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>
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* test__xxsubinterpreters
* test_builtin
* test_doctest
* test_exceptions
* test_opcodes
* test_support
* test_argparse
* test_baseexception
* test_bdb
* test_bool
* test_asdl_parser
|
| |
|
| |
|
|
|
|
| |
(GH-25006)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
(GH-24939)
|
|
|
|
|
| |
the line (GH-24973)
Co-authored-by: Erlend Egeberg Aasland
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
Don't redefine Py_DebugFlag, it's already defined in pydebug.h which
is included by Python.h
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
|
|
|
| |
from stdin (GH-24763)
|
|
|
|
| |
(GH-24479)
|
|
|
|
|
| |
Co-authored-by: Guido van Rossum <guido@python.org>
Co-authored-by: Talin <viridia@gmail.com>
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
|
|
|
|
|
|
| |
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.
|