summaryrefslogtreecommitdiffstats
path: root/Parser
Commit message (Collapse)AuthorAgeFilesLines
* gh-90994: Improve error messages upon call arguments syntax errors (GH-96893)Lysandros Nikolaou2022-11-201-1149/+1395
|
* gh-99581: Fix a buffer overflow in the tokenizer when copying lines that ↵Pablo Galindo Salgado2022-11-201-1/+6
| | | | fill the available buffer (#99605)
* gh-99211: Point to except/except* on syntax errors when mixing them (GH-99215)Lysandros Nikolaou2022-11-201-671/+713
| | | Automerge-Triggered-By: GH:lysnikolaou
* gh-81057: Move Globals in Core Code to _PyRuntimeState (gh-99496)Eric Snow2022-11-151-0/+1
| | | | | This is the first of several changes to consolidate non-object globals in core code. https://github.com/python/cpython/issues/81057
* gh-99300: Use Py_NewRef() in Python/Python-ast.c (#99499)Victor Stinner2022-11-151-4/+5
| | | | | | Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and Py_XNewRef() in Python/Python-ast.c. Update Parser/asdl_c.py to regenerate code.
* gh-81057: Move Global Variables Holding Objects to _PyRuntimeState. (gh-99487)Eric Snow2022-11-141-0/+4
| | | | | This moves nearly all remaining object-holding globals in core code (other than static types). https://github.com/python/cpython/issues/81057
* gh-99300: Use Py_NewRef() in Parser/ directory (#99330)Victor Stinner2022-11-103-9/+4
| | | | Replace Py_INCREF() with Py_NewRef() in C files of the Parser/ directory and in the PEG generator.
* gh-99300: Use Py_NewRef() in Python/ directory (#99317)Victor Stinner2022-11-101-8/+7
| | | | | | Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and Py_XNewRef() in C files of the Python/ directory. Update Parser/asdl_c.py to regenerate Python/Python-ast.c.
* gh-99153: set location on SyntaxError for try with both except and except* ↵Irit Katriel2022-11-061-3/+3
| | | | (GH-99160)
* gh-98401: Invalid escape sequences emits SyntaxWarning (#99011)Victor Stinner2022-11-031-2/+9
| | | | | | | | | | | | | | | | | | | | | | A backslash-character pair that is not a valid escape sequence now generates a SyntaxWarning, instead of DeprecationWarning. For example, re.compile("\d+\.\d+") now emits a SyntaxWarning ("\d" is an invalid escape sequence), use raw strings for regular expression: re.compile(r"\d+\.\d+"). In a future Python version, SyntaxError will eventually be raised, instead of SyntaxWarning. Octal escapes with value larger than 0o377 (ex: "\477"), deprecated in Python 3.11, now produce a SyntaxWarning, instead of DeprecationWarning. In a future Python version they will be eventually a SyntaxError. codecs.escape_decode() and codecs.unicode_escape_decode() are left unchanged: they still emit DeprecationWarning. * The parser only emits SyntaxWarning for Python 3.12 (feature version), and still emits DeprecationWarning on older Python versions. * Fix SyntaxWarning by using raw strings in Tools/c-analyzer/ and wasm_build.py.
* gh-98931: Improve error message when the user types 'import x from y' ↵Pablo Galindo Salgado2022-11-011-391/+465
| | | | instead of 'from y import x' (#98932)
* gh-97669: Create Tools/build/ directory (#97963)Victor Stinner2022-10-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Create Tools/build/ directory. Move the following scripts from Tools/scripts/ to Tools/build/: * check_extension_modules.py * deepfreeze.py * freeze_modules.py * generate_global_objects.py * generate_levenshtein_examples.py * generate_opcode_h.py * generate_re_casefix.py * generate_sre_constants.py * generate_stdlib_module_names.py * generate_token.py * parse_html5_entities.py * smelly.py * stable_abi.py * umarshal.py * update_file.py * verify_ensurepip_wheels.py Update references to these scripts.
* gh-97997: Add col_offset field to tokenizer and use that for AST nodes (#98000)Lysandros Nikolaou2022-10-072-11/+43
|
* gh-97973: Return all necessary information from the tokenizer (GH-97984)Lysandros Nikolaou2022-10-064-137/+150
| | | | | Right now, the tokenizer only returns type and two pointers to the start and end of the token. This PR modifies the tokenizer to return the type and set all of the necessary information, so that the parser does not have to this.
* GH-91079: Decouple C stack overflow checks from Python recursion checks. ↵Mark Shannon2022-10-051-6/+3
| | | | (GH-96510)
* gh-96670: Raise SyntaxError when parsing NULL bytes (#97594)Pablo Galindo Salgado2022-09-271-4/+15
|
* gh-91210: Improve error message when non-default param follows default ↵Lysandros Nikolaou2022-09-171-345/+353
| | | | | | (GH-95933) - Improve error message when parameter without a default follows one with a default - Show same error message when positional-only params precede the default/non-default sequence
* gh-96678: Fix UB of null pointer arithmetic (GH-96782)Matthias Görgens2022-09-131-1/+1
| | | Automerge-Triggered-By: GH:pablogsal
* gh-96268: Fix loading invalid UTF-8 (#96270)Michael Droettboom2022-09-071-13/+45
| | | | | This makes tokenizer.c:valid_utf8 match stringlib/codecs.h:decode_utf8. It also fixes an off-by-one error introduced in 3.10 for the line number when the tokenizer reports bad UTF8.
* gh-96611: Fix error message for invalid UTF-8 in mid-multiline string (#96623)Michael Droettboom2022-09-061-0/+2
|
* gh-96587: Raise `SyntaxError` for PEP654 on older `feature_version` (#96588)Nikita Sobolev2022-09-051-1/+1
|
* gh-95778: CVE-2020-10735: Prevent DoS by very large int() (#96499)Gregory P. Smith2022-09-021-0/+23
| | | | | | | | | | | | | | | | Integer to and from text conversions via CPython's bignum `int` type is not safe against denial of service attacks due to malicious input. Very large input strings with hundred thousands of digits can consume several CPU seconds. This PR comes fresh from a pile of work done in our private PSRT security response team repo. Signed-off-by: Christian Heimes [Red Hat] <christian@python.org> Tons-of-polishing-up-by: Gregory P. Smith [Google] <greg@krypto.org> Reviews via the private PSRT repo via many others (see the NEWS entry in the PR). <!-- gh-issue-number: gh-95778 --> * Issue: gh-95778 <!-- /gh-issue-number --> I wrote up [a one pager for the release managers](https://docs.google.com/document/d/1KjuF_aXlzPUxTK4BMgezGJ2Pn7uevfX7g0_mvgHlL7Y/edit#). Much of that text wound up in the Issue. Backports PRs already exist. See the issue for links.
* gh-94996: Disallow lambda pos only params with feature_version < (3, 8) ↵Shantanu2022-08-121-2/+2
| | | | (GH-95934)
* gh-94996: Disallow parsing pos only params with feature_version < (3, 8) ↵Shantanu2022-08-121-2/+2
| | | | (GH-94997)
* gh-95876: Fix format string in pegen error location code (#95877)Christian Heimes2022-08-111-1/+1
|
* gh-95355: Check tokens[0] after allocating memory (GH-95356)Honglin Zhu2022-07-281-1/+1
| | | | | #95355 Automerge-Triggered-By: GH:pablogsal
* gh-95185: Check recursion depth in the AST constructor (#95186)Pablo Galindo Salgado2022-07-241-1/+36
| | | Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-94949: Disallow parsing parenthesised ctx mgr with old feature_version ↵Shantanu2022-07-181-1/+1
| | | | | | | | | | | (#94950) * gh-94949: Disallow parsing parenthesised ctx manager with old feature_version * 📜🤖 Added by blurb_it. * Allow it with feature_version=(3, 9) as well Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* gh-94947: Disallow parsing walrus with feature_version < (3, 8) (#94948)Shantanu2022-07-181-1/+1
| | | | | | | | | * gh-94947: Disallow parsing walrus with feature_version < (3, 8) * oops, commit the parser * 📜🤖 Added by blurb_it. Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* gh-94869: Fix the location in some expressions for multi-line f-string ast ↵Pablo Galindo Salgado2022-07-161-1/+4
| | | | nodes (#94895)
* [3.11] bpo-14916: interactive fd is not tied to stdin [type-bug] (#91469)Paul m. p. Peny2022-07-161-1/+1
| | | | | | | | | | | * bpo-14916: interactive fd is not always stdin related to https://github.com/python/cpython/pull/31006 merged bugfix following https://bugs.python.org/issue14916 * 📜🤖 Added by blurb_it. Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* gh-94360: Fix a tokenizer crash when reading encoded files with syntax ↵Pablo Galindo Salgado2022-07-052-5/+13
| | | | | | | | | | | errors from stdin (#94386) * gh-94360: Fix a tokenizer crash when reading encoded files with syntax errors from stdin Signed-off-by: Pablo Galindo <pablogsal@gmail.com> * nitty nit Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* gh-94192: Fix error for dictionary literals with invalid expression as ↵wookie1842022-06-261-261/+326
| | | | | | | value. (#94304) * Fix error for dictionary literals with invalid expression as value. * Remove trailing whitespace
* gh-92858: Improve error message for some suites with syntax error before ':' ↵wookie1842022-06-231-362/+500
| | | | (#92894)
* gh-84623: Remove unused imports (#94132)Victor Stinner2022-06-221-1/+0
|
* gh-93937: PyOS_StdioReadline() uses PyConfig.legacy_windows_stdio (#94024)Victor Stinner2022-06-201-1/+2
| | | | | | | On Windows, PyOS_StdioReadline() now gets PyConfig.legacy_windows_stdio from _PyOS_ReadlineTState, rather than using the deprecated global Py_LegacyWindowsStdioFlag variable. Fix also a compiler warning in Py_SetStandardStreamEncoding().
* gh-93741: Add private C API _PyImport_GetModuleAttrString() (GH-93742)Serhiy Storchaka2022-06-142-12/+6
| | | | | | It combines PyImport_ImportModule() and PyObject_GetAttrString() and saves 4-6 lines of code on every use. Add also _PyImport_GetModuleAttr() which takes Python strings as arguments.
* gh-93671: Avoid exponential backtracking in deeply nested sequence patterns ↵Pablo Galindo Salgado2022-06-101-0/+10
| | | | | in match statements (GH-93680) Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* gh-93418: Fix an assert when an f-string expression is followed by an '=', ↵Eric V. Smith2022-06-011-1/+3
| | | | but no closing brace. (gh-93419)
* gh-92597: Ensure that AST nodes without explicit end positions can be ↵Pablo Galindo Salgado2022-05-311-1/+13
| | | | compiled (GH-93359)
* gh-93283: Improve error message for f-string with invalid conversion ↵Serhiy Storchaka2022-05-311-12/+28
| | | | character (GH-93349)
* GH-93207: Remove HAVE_STDARG_PROTOTYPES configure check for stdarg.h (#93215)Kumar Aditya2022-05-271-12/+0
|
* gh-93103: Parser uses PyConfig.parser_debug instead of Py_DebugFlag (#93106)Victor Stinner2022-05-245-2/+12
| | | | | | | * Replace deprecated Py_DebugFlag with PyConfig.parser_debug in the parser. * Add Parser.debug member. * Add tok_state.debug member. * Py_FrozenMain(): Replace Py_VerboseFlag with PyConfig.verbose.
* gh-90473: Decrease recursion limit and skip tests on WASI (GH-92803)Christian Heimes2022-05-191-1/+5
|
* gh-92651: Remove the Include/token.h header file (#92652)Victor Stinner2022-05-114-9/+9
| | | | | | | | | | | | | | | Remove the token.h header file. There was never any public tokenizer C API. The token.h header file was only designed to be used by Python internals. Move Include/token.h to Include/internal/pycore_token.h. Including this header file now requires that the Py_BUILD_CORE macro is defined. It no longer checks for the Py_LIMITED_API macro. Rename functions: * PyToken_OneChar() => _PyToken_OneChar() * PyToken_TwoChars() => _PyToken_TwoChars() * PyToken_ThreeChars() => _PyToken_ThreeChars()
* Use static inline function Py_EnterRecursiveCall() (#91988)Victor Stinner2022-05-041-5/+6
| | | | | | | | | | | | | | | | Currently, calling Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() may use a function call or a static inline function call, depending if the internal pycore_ceval.h header file is included or not. Use a different name for the static inline function to ensure that the static inline function is always used in Python internals for best performance. Similar approach than PyThreadState_GET() (function call) and _PyThreadState_GET() (static inline function). * Rename _Py_EnterRecursiveCall() to _Py_EnterRecursiveCallTstate() * Rename _Py_LeaveRecursiveCall() to _Py_LeaveRecursiveCallTstate() * pycore_ceval.h: Rename Py_EnterRecursiveCall() to _Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() and _Py_LeaveRecursiveCall()
* gh-81548: Deprecate octal escape sequences with value larger than 0o377 ↵Serhiy Storchaka2022-04-301-7/+18
| | | | (GH-91668)
* gh-87999: Change warning type for numeric literal followed by keyword (GH-91980)Serhiy Storchaka2022-04-271-4/+6
| | | | | The warning emitted by the Python parser for a numeric literal immediately followed by keyword has been changed from deprecation warning to syntax warning.
* bpo-47212: Improve error messages for un-parenthesized generator expressions ↵Matthieu Dartiailh2022-04-053-4/+5
| | | | (GH-32302)
* bpo-46315: Use fopencookie only on Emscripten 3.x and newer (GH-32266)Christian Heimes2022-04-021-1/+1
|