summaryrefslogtreecommitdiffstats
path: root/Parser
Commit message (Collapse)AuthorAgeFilesLines
* [3.13] gh-133157: fix UBSan failures in `Parser/pegen.c` (GH-134048) (#135334)Bénédikt Tran2025-06-103-81/+75
| | | | [3.13] gh-133157: fix UBSan failures in `Parser/pegen.c` (GH-134048) (cherry picked from commit 754e7c9b5187fcad22acf7555479603f173a4a09)
* [3.13] gh-133767: Fix use-after-free in the unicode-escape decoder with an ↵Serhiy Storchaka2025-05-201-10/+16
| | | | | | | | | | | | | | | | | error handler (GH-129648) (GH-133944) If the error handler is used, a new bytes object is created to set as the object attribute of UnicodeDecodeError, and that bytes object then replaces the original data. A pointer to the decoded data will became invalid after destroying that temporary bytes object. So we need other way to return the first invalid escape from _PyUnicode_DecodeUnicodeEscapeInternal(). _PyBytes_DecodeEscape() does not have such issue, because it does not use the error handlers registry, but it should be changed for compatibility with _PyUnicode_DecodeUnicodeEscapeInternal(). (cherry picked from commit 9f69a58623bd01349a18ba0c7a9cb1dad6a51e8e) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.13] gh-133516: Raise `ValueError` when constants `True`, `False` or ↵TERESH12025-05-081-0/+15
| | | | `None` are used as an identifier after NFKC normalization (GH-133523) (#133615)
* [3.13] gh-132769: Refactor possible read-out-of-bounds in `lexer.c` ↵Miss Islington (bot)2025-04-211-1/+1
| | | | | | | | (GH-132770) (#132788) gh-132769: Refactor possible read-out-of-bounds in `lexer.c` (GH-132770) (cherry picked from commit ea8ec95cfadbf58a11ef8e41341254d982a1a479) Co-authored-by: sobolevn <mail@sobolevn.me>
* [3.13] gh-129958: Properly disallow newlines in format specs in ↵Łukasz Langa2025-04-181-0/+8
| | | | | | | single-quoted f-strings (GH-130063) (GH-132692) (cherry picked from commit 2f8b08da475152adea59b6bf98e2d0cb73dd8a59) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* [3.13] gh-131762: Fixed dereferencing the pointer 'parser_token->metadata' ↵Miss Islington (bot)2025-03-261-1/+1
| | | | | | | | with a NULL value (GH-131764) (#131774) gh-131762: Fixed dereferencing the pointer 'parser_token->metadata' with a NULL value (GH-131764) (cherry picked from commit 2c686a9ac243800b630d4a09622c8eb789f5b354) Co-authored-by: rialbat <47256826+rialbat@users.noreply.github.com>
* [3.13] gh-125331: Allow the parser to activate future imports on the fly ↵Miss Islington (bot)2025-03-103-1/+18
| | | | | | | | (GH-125482) (#131062) gh-125331: Allow the parser to activate future imports on the fly (GH-125482) (cherry picked from commit 3bd3e09588bfde7edba78c55794a0e28e2d21ea5) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* [3.13] gh-130740: Move some `stdbool.h` includes after `Python.h` (#130738) ↵Bénédikt Tran2025-03-031-2/+2
| | | | | | | | | | | | | | | | (#130756) gh-130740: Move some `stdbool.h` includes after `Python.h` (#130738) Move some `#include <stdbool.h>` after `#include "Python.h"` when `pyconfig.h` is not included first and when we are in a platform-agnostic context. This is to avoid having features defined by `stdbool.h` before those decided by `Python.h` (this caused some build failures when compiling CPython with `zig cc`). (cherry-picked from commit 214562ed4ddc248b007f718ed92ebcc0c3669611) --------- Co-authored-by: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
* [3.13] gh-130618: Fix parser error when using lambdas inside f-strings ↵Pablo Galindo Salgado2025-03-011-1/+5
| | | | | | | (GH-130638) (#130642) (cherry picked from commit e06bebb87e1b33f7251196e1ddb566f528c3fc98) Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
* [3.13] gh-116042: Fix location for SyntaxErrors of invalid escapes in the ↵Pablo Galindo Salgado2025-02-132-9/+48
| | | | | | tokenizer (GH-116049) (#130066) (cherry picked from commit 56eda256336310a08d4beb75b998488cb359444b) (cherry picked from commit 369704b428982968346c1482fccdac8b25fdd836)
* [3.13] gh-124363: Treat debug expressions in f-string as raw strings ↵Miss Islington (bot)2025-01-221-43/+36
| | | | | | | | | | (GH-128399) (#129187) gh-124363: Treat debug expressions in f-string as raw strings (GH-128399) (cherry picked from commit 60a3a0dd6fe140fdc87f6e769ee5bb17d92efe4e) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* [3.13] gh-129093: Fix f-string debug text sometimes getting cut off when ↵Miss Islington (bot)2025-01-221-3/+1
| | | | | | | | expression contains `!` (GH-129159) (#129163) gh-129093: Fix f-string debug text sometimes getting cut off when expression contains `!` (GH-129159) (cherry picked from commit 767cf708449fbf13826d379ecef64af97d779510) Co-authored-by: Tomas R <tomas.roun8@gmail.com>
* [3.13] gh-126240: handle `NULL` returned by `_Py_asdl_expr_seq_new` ↵Miss Islington (bot)2024-10-311-0/+9
| | | | | | | | | | (GH-126241) (#126243) gh-126240: handle `NULL` returned by `_Py_asdl_expr_seq_new` (GH-126241) check return value of `_Py_asdl_expr_seq_new` (cherry picked from commit 94639f6b7182c2e1a82f2f907b03b5b15202acfa) Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* [3.13] gh-126105: Fix crash in `ast` module, when `._fields` is deleted ↵Miss Islington (bot)2024-10-291-10/+8
| | | | | | | | | | (GH-126115) (#126130) gh-126105: Fix crash in `ast` module, when `._fields` is deleted (GH-126115) Previously, if the `ast.AST._fields` attribute was deleted, attempts to create a new `as`t node would crash due to the assumption that `_fields` always had a non-NULL value. Now it has been fixed by adding an extra check to ensure that `_fields` does not have a NULL value (this can happen when you manually remove `_fields` attribute). (cherry picked from commit b2eaa75b176e07730215d76d8dce4d63fb493391) Co-authored-by: sobolevn <mail@sobolevn.me>
* [3.13] gh-125268: Use static string for "1e309" in AST (GH-125272) (GH-125280)Sam Gross2024-10-241-2/+0
| | | | | | When formatting the AST as a string, infinite values are replaced by 1e309, which evaluates to infinity. The initialization of this string replacement was not thread-safe in the free threading build. (cherry picked from commit 427dcf24de4e06d239745d74d08c4b2e541dca5a)
* [3.13] gh-124064: Fix -Wconversion warnings in Parser/string_parser.c ↵Miss Islington (bot)2024-09-301-8/+8
| | | | | | | | | | | (GH-124204) (#124216) gh-124064: Fix -Wconversion warnings in Parser/string_parser.c (GH-124204) Fix integer overflow check in decode_unicode_with_escapes(): use PY_SSIZE_T_MAX instead of SIZE_MAX. (cherry picked from commit f9fa6ba4f8d90ae12bc1f6a792d66903bb169ba8) Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.13] gh-123321: Make Parser/myreadline.c locking safe in free-threaded ↵Miss Islington (bot)2024-09-061-23/+10
| | | | | | | | | | | | build (GH-123690) (#123798) gh-123321: Make Parser/myreadline.c locking safe in free-threaded build (GH-123690) Use a `PyMutex` to avoid the race in mutex initialization. Use relaxed atomics to avoid the data race on reading `_PyOS_ReadlineTState` when checking for re-entrant calls. (cherry picked from commit 0c080d7c77d826c1afab7bd6b73f61e714cffcb7) Co-authored-by: Sam Gross <colesbury@gmail.com>
* [3.13] gh-123321: Fix Parser/myreadline.c to prevent a segfault during a ↵Miss Islington (bot)2024-09-041-3/+10
| | | | | | | | multi-threaded race (GH-123323) (#123676) gh-123321: Fix Parser/myreadline.c to prevent a segfault during a multi-threaded race (GH-123323) (cherry picked from commit a4562fedadb73fe1e978dece65c3bcefb4606678) Co-authored-by: Bar Harel <bharel@barharel.com>
* [3.13] gh-123229: Fix valgrind warning by initializing the f-string buffers ↵Miss Islington (bot)2024-08-231-1/+2
| | | | | | | | | to 0 in the tokenizer (GH-123263) (#123264) gh-123229: Fix valgrind warning by initializing the f-string buffers to 0 in the tokenizer (GH-123263) (cherry picked from commit adc5190014efcf7b7a4c5dfc9998faa8345527ed) Signed-off-by: Pablo Galindo <pablogsal@gmail.com> Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* [3.13] gh-122581: Avoid data races when collecting parser statistics ↵Miss Islington (bot)2024-08-071-0/+17
| | | | | | | | (GH-122694) (#122733) gh-122581: Avoid data races when collecting parser statistics (GH-122694) (cherry picked from commit ce0d66c8d238c9676c6ecd3f04294a3299e07f74) Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
* [3.13] gh-122300: Preserve AST nodes for format specifiers with single ↵Pablo Galindo Salgado2024-07-271-1/+2
| | | | | elements (GH-122308) (#122364) (cherry picked from commit db2d8b6db1b56c2bd3802b86f9b76da33e8898d7)
* [3.13] gh-122270: Fix typos in the Py_DEBUG macro name (GH-122271) (GH-122275)Miss Islington (bot)2024-07-251-1/+1
| | | | | (cherry picked from commit 6c09b8de5c67406113e8d082e05c9587e35a852a) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.13] gh-122026: Fix identification of mismatched parentheses inside ↵Miss Islington (bot)2024-07-191-0/+3
| | | | f-strings (GH-122028) (#122041)
* [3.13] gh-121905: Consistently use "floating-point" instead of "floating ↵Serhiy Storchaka2024-07-191-1/+1
| | | | | point" (GH-121907) (GH-122012) (cherry picked from commit 1a0c7b9ba48a2dffb70bb0c7327abae1d3e87356)
* [3.13] gh-121130: Fix f-string format specifiers with debug expressions ↵Pablo Galindo Salgado2024-07-164-27/+62
| | | | | (GH-121150) (#121868) (cherry picked from commit c46d64e0ef8e92a6b4ab4805d813d7e4d6663380)
* [3.13] gh-121332: Make AST node constructor check _attributes instead of ↵Jelle Zijlstra2024-07-111-14/+25
| | | | | hardcoding attributes (GH-121334) (#121625) (cherry picked from commit 58e8cf2bb61f82df9eabd1209fe5e3d146e4c8cd)
* [3.13] gh-120155: Fix Coverity issue in parse_string() (GH-120997) (#121005)Miss Islington (bot)2024-06-251-0/+5
| | | | | | gh-120155: Fix Coverity issue in parse_string() (GH-120997) (cherry picked from commit 769aea332940f03c3e5b1ad9badd6635c1ac992a) Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.13] gh-120108: Fix deepcopying of AST trees with .parent attributes ↵Jelle Zijlstra2024-06-251-17/+14
| | | | | (GH-120114) (#121000) (cherry picked from commit 42b2c9d78da7ebd6bd5925a4d4c78aec3c9e78e6)
* [3.13] gh-113993: Allow interned strings to be mortal, and fix related ↵Petr Viktorin2024-06-242-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | issues (GH-120520) (GH-120945) * Add an InternalDocs file describing how interning should work and how to use it. * Add internal functions to *explicitly* request what kind of interning is done: - `_PyUnicode_InternMortal` - `_PyUnicode_InternImmortal` - `_PyUnicode_InternStatic` * Switch uses of `PyUnicode_InternInPlace` to those. * Disallow using `_Py_SetImmortal` on strings directly. You should use `_PyUnicode_InternImmortal` instead: - Strings should be interned before immortalization, otherwise you're possibly interning a immortalizing copy. - `_Py_SetImmortal` doesn't handle the `SSTATE_INTERNED_MORTAL` to `SSTATE_INTERNED_IMMORTAL` update, and those flags can't be changed in backports, as they are now part of public API and version-specific ABI. * Add private `_only_immortal` argument for `sys.getunicodeinternedsize`, used in refleak test machinery. * Make sure the statically allocated string singletons are unique. This means these sets are now disjoint: - `_Py_ID` - `_Py_STR` (including the empty string) - one-character latin-1 singletons Now, when you intern a singleton, that exact singleton will be interned. * Add a `_Py_LATIN1_CHR` macro, use it instead of `_Py_ID`/`_Py_STR` for one-character latin-1 singletons everywhere (including Clinic). * Intern `_Py_STR` singletons at startup. * For free-threaded builds, intern `_Py_LATIN1_CHR` singletons at startup. * Beef up the tests. Cover internal details (marked with `@cpython_only`). * Add lots of assertions Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
* [3.13] gh-119521: Rename IncompleteInputError to _IncompleteInputError and ↵Miss Islington (bot)2024-06-241-0/+1
| | | | | | | | | | | | | remove from public API/ABI (GH-119680, GH-120955) (GH-120944) - gh-119521: Rename IncompleteInputError to _IncompleteInputError and remove from public API/ABI (GH-119680) (cherry picked from commit ce1064e4c9bcfd673323ad690e60f86e1ab907bb) - gh-119521: Use `PyAPI_DATA`, not `extern`, for `_PyExc_IncompleteInputError` (GH-120955) (cherry picked from commit ac61d58db0753a3b37de21dbc6e86b38f2a93f1b) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com> Co-authored-by: Petr Viktorin <encukou@gmail.com>
* [3.13] gh-119724: Revert "bpo-45759: Better error messages for non-matching ↵T. Wouters2024-06-041-547/+449
| | | | | | | | 'elif'/'else' statements (GH-29513)" (GH-119974) (GH-120013) This reverts commit 1c8f912ebdfdb146cd7dd2d7a3a67d2c5045ddb0. (cherry picked from commit 31a4fb3c74a0284436343858803b54471e2dc9c7)
* [3.13] gh-119118: Fix performance regression in tokenize module (GH-119615) ↵Miss Islington (bot)2024-05-282-0/+26
| | | | | | | | | | | | | (#119682) - Cache line object to avoid creating a Unicode object for all of the tokens in the same line. - Speed up byte offset to column offset conversion by using the smallest buffer possible to measure the difference. (cherry picked from commit d87b0151062e36e67f9e42e1595fba5bf23a485c) Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com> Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* [3.13] gh-118851: Default ctx arguments to AST constructors to Load() ↵Miss Islington (bot)2024-05-091-0/+7
| | | | | | | | (GH-118854) (#118871) (cherry picked from commit 68fbc00dc870f6a8dcbecd2ec19298e21015867f) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* gh-118090: Improve error message for empty type param brackets (GH-118091)Nikita Sobolev2024-05-071-797/+962
|
* gh-117486: Improve behavior for user-defined AST subclasses (#118212)Jelle Zijlstra2024-05-061-14/+17
| | | | | | | | Now, such classes will no longer require changes in Python 3.13 in the normal case. The test suite for robotframework passes with no DeprecationWarnings under this PR. I also added a new DeprecationWarning for the case where `_field_types` exists but is incomplete, since that seems likely to indicate a user mistake.
* gh-116322: Add Py_mod_gil module slot (#116882)Brett Simmers2024-05-031-0/+1
| | | | | | | | | | | | | | This PR adds the ability to enable the GIL if it was disabled at interpreter startup, and modifies the multi-phase module initialization path to enable the GIL when loading a module, unless that module's spec includes a slot indicating it can run safely without the GIL. PEP 703 called the constant for the slot `Py_mod_gil_not_used`; I went with `Py_MOD_GIL_NOT_USED` for consistency with gh-104148. A warning will be issued up to once per interpreter for the first GIL-using module that is loaded. If `-v` is given, a shorter message will be printed to stderr every time a GIL-using module is loaded (including the first one that issues a warning).
* gh-116126: Implement PEP 696 (#116129)Jelle Zijlstra2024-05-032-446/+551
| | | | | Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
* gh-116988: Remove duplicates of `annotated_rhs` in the Grammar (#117004)David Rubin2024-04-241-2091/+1560
|
* gh-118082: Improve `import` without names syntax error message (#118083)Nikita Sobolev2024-04-231-149/+200
|
* gh-109120: Fix syntax error in handlinh of incorrect star expressions (#117444)Grigoriev Semyon2024-04-021-1230/+1417
|
* gh-117266: Fix crashes on user-created AST subclasses (GH-117276)Jelle Zijlstra2024-03-281-2/+13
| | | Fix crashes on user-created AST subclasses
* bpo-24612: Improve syntax error for 'not' after an operator (GH-28170)Pablo Galindo Salgado2024-03-261-594/+970
| | | Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
* gh-116437: Use new C API PyDict_Pop() to simplify the code (GH-116438)Serhiy Storchaka2024-03-071-9/+9
|
* gh-105858: Improve AST node constructors (#105880)Jelle Zijlstra2024-02-281-7/+231
| | | | | | | | | | | | | | | | | Demonstration: >>> ast.FunctionDef.__annotations__ {'name': <class 'str'>, 'args': <class 'ast.arguments'>, 'body': list[ast.stmt], 'decorator_list': list[ast.expr], 'returns': ast.expr | None, 'type_comment': str | None, 'type_params': list[ast.type_param]} >>> ast.FunctionDef() <stdin>:1: DeprecationWarning: FunctionDef.__init__ missing 1 required positional argument: 'name'. This will become an error in Python 3.15. <stdin>:1: DeprecationWarning: FunctionDef.__init__ missing 1 required positional argument: 'args'. This will become an error in Python 3.15. <ast.FunctionDef object at 0x101959460> >>> node = ast.FunctionDef(name="foo", args=ast.arguments()) >>> node.decorator_list [] >>> ast.FunctionDef(whatever="you want", name="x", args=ast.arguments()) <stdin>:1: DeprecationWarning: FunctionDef.__init__ got an unexpected keyword argument 'whatever'. Support for arbitrary keyword arguments is deprecated and will be removed in Python 3.15. <ast.FunctionDef object at 0x1019581f0>
* gh-115823: Calculate correctly error locations when dealing with implicit ↵Pablo Galindo Salgado2024-02-261-11/+9
| | | | encodings (#115824)
* gh-115881: Ensure `ast.parse()` parses conditional context managers even ↵Alex Waygood2024-02-261-1/+1
| | | | with low `feature_version` passed (#115920)
* gh-113744: Add a new IncompleteInputError exception to improve incomplete ↵Pablo Galindo Salgado2024-01-301-1/+1
| | | | | input detection in the codeop module (#113745) Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
* gh-114569: Use PyMem_* APIs for most non-PyObject uses (#114574)Erlend E. Aasland2024-01-261-2/+2
| | | Fix usage in Modules, Objects, and Parser subdirectories.
* GH-113655: Lower the C recursion limit on various platforms (GH-113944)Mark Shannon2024-01-161-3/+2
|
* gh-111488: Changed error message in case of no 'in' keyword after 'for' in ↵Grigoriev Semyon2024-01-061-1592/+1785
| | | | cmp (#113656)