1361 Commits

Author SHA1 Message Date
Brian Schubert bdedc4a20e gh-116021: Deprecate support for instantiating abstract AST nodes (#137865)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2026-05-02 09:50:06 -07:00
Brian Schubert d2f506ae07 gh-137600: Promote ast node constructor deprecation warnings to errors (#137601)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2026-04-28 02:51:06 +00:00
Bartosz Sławecki 448d7b96c1 gh-145239: Accept unary plus literal pattern (#148566)
Add '+' alternatives to signed_number and signed_real_number grammar
rules, mirroring how unary minus is already handled for pattern matching.
Unary plus is a no-op on numbers so the value is returned directly without
wrapping in a UnaryOp node.
2026-04-23 22:07:28 +03:00
Stan Ulbrych 1795fccfbc gh-148157: Check for _PyPegen_add_type_comment_to_arg fail in _PyPegen_name_default_pair (#148158) 2026-04-06 12:56:36 +01:00
Karolina Surma 1887a95f51 gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770)
Rename from _Py_INTERNAL_ABI_SLOT to _Py_ABI_SLOT
and define the macro using _PyABIInfo_DEFAULT.

Use the ABI slot in stdlib extension modules to enable running
a check of ABI version compatibility.

_tkinter, _tracemalloc and readline don't use the slots, hence they need
explicit handling.

Co-authored-by: Victor Stinner <vstinner@python.org>
2026-03-24 17:47:55 +00:00
Stan Ulbrych e1c224624a gh-145783: Propagate errors raised in NEW_TYPE_COMMENT (#145784) 2026-03-13 11:05:20 +00:00
Shamil 86a0756234 gh-140594: Fix an out of bounds read when feeding NUL byte to PyOS_StdioReadline() (#140910)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-03-12 10:46:36 +00:00
Sergey Miryanov d19de375a2 GH-145247: Use _PyTuple_FromPair in Parser and Python (#145842)
Use _PyTuple_FromPair in Parser and Python
2026-03-11 21:08:18 +00:00
Pieter Eendebak 4f87c99a5a gh-145376: Fix refleak & pointer type bug in uncommon code paths in Parser/ (GH-145684) 2026-03-11 14:24:15 +01:00
Pablo Galindo Salgado 09e8c38231 gh-145241: specialize SyntaxError for single trailing-comma with item (#145282)
Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
2026-02-28 02:24:06 +00:00
Pablo Galindo Salgado 98b1e51927 gh-145234: Normalize decoded CR in string tokenizer (#145281) 2026-02-27 12:44:54 +00:00
AdamKorcz 3fc945df22 gh-144872: fix heap buffer overflow _PyTokenizer_ensure_utf8 (#144807) 2026-02-26 22:35:08 +00:00
Ramin Farajpour Cami e6110efd03 gh-144759: Fix undefined behavior from NULL pointer arithmetic in lexer (#144788)
Guard against NULL pointer arithmetic in `_PyLexer_remember_fstring_buffers`
and `_PyLexer_restore_fstring_buffers`. When `start` or `multi_line_start`
are NULL (uninitialized in tok_mode_stack[0]), performing `NULL - tok->buf`
is undefined behavior. Add explicit NULL checks to store -1 as sentinel
and restore NULL accordingly.

Add test_lexer_buffer_realloc_with_null_start to test_repl.py that
exercises the code path where the lexer buffer is reallocated while
tok_mode_stack[0] has NULL start/multi_line_start pointers. This
triggers _PyLexer_remember_fstring_buffers and verifies the NULL
checks prevent undefined behavior.
2026-02-15 14:39:57 +00:00
Pablo Galindo Salgado 46d5106cfa gh-142349: Implement PEP 810 - Explicit lazy imports (#142351)
Co-authored-by: T. Wouters <twouters@meta.com >
Co-authored-by: Brittany Reynoso <breynoso@meta.com>
Co-authored-by: Dino Viehland <dinoviehland@meta.com>
2026-02-12 00:15:33 +00:00
adam j hartz ccbe41e27c gh-143055: Implementation of PEP 798 (#143056)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2026-01-30 20:37:52 -08:00
cui 0fa1fc69f3 gh-144322: typo This errors to These errors (#144323) 2026-01-29 13:26:38 +00:00
Jelle Zijlstra 639c1ad4f1 gh-144169: Fix three crashes in AST objects with non-str kwargs (#144178)
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-01-25 17:28:58 -08:00
Samuel f37f57dfe6 gh-131421: Fix ASDL kw_defaults being expr* instead of expr?* (GH-133773)
Also fix docs ASDL highlighting.
2025-12-29 13:43:09 +02:00
Sam Gross 2b4feee648 gh-122581: Use parser mutex in default build for subinterpreters (gh-142959) 2025-12-20 15:37:31 -05:00
AZero13 d844d22cb0 gh-142724: fix error path in _PyPegen_raise_tokenizer_init_error (#142725) 2025-12-14 21:23:38 +00:00
Pablo Galindo Salgado c433986005 gh-142236: Improve error location for missing comma in string concatenations (#142330) 2025-12-11 14:47:26 +00:00
Victor Stinner 7fe1a18b77 gh-130396: Remove _Py_ReachedRecursionLimitWithMargin() function (#141951)
Move the private function to the internal C API (pycore_ceval.h).
2025-11-27 12:32:00 +01:00
Serhiy Storchaka d8e6bdc0d0 gh-135801: Add the module parameter to compile() etc (GH-139652)
Many functions related to compiling or parsing Python code, such as
compile(), ast.parse(), symtable.symtable(),
and importlib.abc.InspectLoader.source_to_code() now allow to pass
the module name used when filtering syntax warnings.
2025-11-13 13:21:32 +02:00
Mikhail Efimov 8706167474 gh-140576: Fixed crash produced by lexer in case of dedented zero byte (#140583) 2025-10-29 13:27:35 +00:00
Brian Schubert 3dab11f888 gh-138944: Fix SyntaxError message for invalid syntax following valid import-as statement (#138945) 2025-10-26 22:35:21 +00:00
sobolevn 92c0c45563 gh-138857: Improve error message for case outside of match (#138858)
* gh-138857: Improve error message for `case` outside of `match`

---------

Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
2025-10-24 11:20:54 +02:00
Stan Ulbrych 95953b692d gh-140471: Fix buffer overflow in AST node initialization with malformed _fields (#140506) 2025-10-23 15:35:21 +00:00
Bartosz Sławecki b3b0d75069 gh-140253: Improve the syntax error from an ill-positioned double-star subpattern (#140254) 2025-10-22 21:29:14 +03:00
Maurycy Pawłowski-Wieroński 459d493ce3 gh-140149: Use PyBytesWriter in _build_concatenated_bytes() (#140150)
Use PyBytesWriter in action_helpers.c _build_concatenated_bytes().
3x faster bytes concat in the parser.

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-10-16 19:24:34 +02:00
Serhiy Storchaka 5c942f11cd gh-63161: Fix PEP 263 support (GH-139481)
* Support non-UTF-8 shebang and comments if non-UTF-8 encoding is specified.
* Detect decoding error in comments for UTF-8 encoding.
* Include the decoding error position for default encoding in SyntaxError.
2025-10-10 12:51:19 +00:00
Tomasz Pytel 539461d9ec gh-139516: Fix lambda colon start format spec in f-string in tokenizer (#139657) 2025-10-07 17:28:15 +01:00
Christoph Walcher 4afa98596e Remove unused prototype _PyPegen_set_source_in_metadata (#138810)
Remove unused prototype
2025-09-12 00:40:49 +00:00
sobolevn cf8f36fe0a gh-138716: Fix assert a := b syntax error message (#138718) 2025-09-10 16:05:16 +03:00
sobolevn 6bc65c30ff gh-136616: Improve assert syntax error messages (#136653) 2025-09-09 23:26:22 +03:00
Pablo Galindo Salgado 4e08a9f97a gh-137078: Fix keyword typo recognition when executed over files (#137079) 2025-08-15 15:14:13 +00:00
Peter Bierma 082f370cdd gh-137514: Add a free-threading wrapper for mutexes (GH-137515)
Add `FT_MUTEX_LOCK`/`FT_MUTEX_UNLOCK`, which call `PyMutex_Lock` and `PyMutex_Unlock` on the free-threaded build, and no-op otherwise.
2025-08-07 11:24:50 -04:00
Pablo Galindo Salgado 0153d82a5a gh-137314: Fix incorrect treatment of format specs in raw fstrings (#137328) 2025-08-03 17:10:51 +01:00
Dave Peck c5e77af131 gh-132661: Disallow Template/str concatenation after PEP 750 spec update (#135996)
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
2025-07-21 08:44:26 +02:00
Pablo Galindo Salgado ef66fb597b gh-135148: Correctly handle f/t strings with comments and debug expressions (#135198) 2025-07-16 11:47:13 +02:00
sobolevn 7e33558455 gh-135422: Fix regression in SyntaxError messages after #134036 (#135423) 2025-06-30 21:52:26 +03:00
Dylan fb9e292919 gh-129958: New syntax error in format spec applies to both f-strings and t-strings (#135570)
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
2025-06-26 15:02:50 +02:00
GiGaGon c2bb3f9843 gh-135496: Fix f string exclamation mark error typo (#135495) 2025-06-14 00:40:42 -04:00
Pablo Galindo Salgado ff2b5f40c2 gh-130077: Properly match full soft keywords in the parser (#135317) 2025-06-10 14:19:03 +01:00
Bénédikt Tran 754e7c9b51 gh-133157: remove usage of _Py_NO_SANITIZE_UNDEFINED in Parser/pegen.c (#134048) 2025-06-10 01:08:30 +01:00
sobolevn 0d9ccc87a2 gh-134036: Improve error messages for invalid raise statements (#134077) 2025-06-06 01:51:06 +01:00
Victor Stinner 6e80f11eb5 gh-135028: Increase parser MAXSTACK for nested parenthesis (#135031) 2025-06-03 08:40:45 +02:00
Victor Stinner f49a07b531 gh-133968: Add PyUnicodeWriter_WriteASCII() function (#133973)
Replace most PyUnicodeWriter_WriteUTF8() calls with
PyUnicodeWriter_WriteASCII().

Unrelated change to please the linter: remove an unused
import in test_ctypes.

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-05-29 14:54:30 +00:00
sobolevn 84914ad0e5 gh-133999: Fix except parsing regression in 3.14 (#134035) 2025-05-17 17:57:02 +03:00
Serhiy Storchaka 9f69a58623 gh-133767: Fix use-after-free in the unicode-escape decoder with an error handler (GH-129648)
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().
2025-05-12 20:42:23 +03:00
Jelle Zijlstra 7dddb4e667 gh-133783: Fix __replace__ on AST nodes for optional attributes (#133797) 2025-05-10 09:17:38 -07:00