Mark Shannon
a45f25361d
GH-131238: More refactoring of core header files (GH-131351)
...
Adds new pycore_stats.h header file to help break dependencies involving the pycore_code.h header.
2025-03-17 14:41:05 +00:00
Victor Stinner
978e37bb5f
gh-131238: Add explicit includes to pycore headers ( #131257 )
2025-03-17 12:32:43 +01:00
Mark Shannon
a1aeec61c4
GH-131238: Core header refactor (GH-131250)
...
* Moves most structs in pycore_ header files into pycore_structs.h and pycore_runtime_structs.h
* Removes many cross-header dependencies
2025-03-17 09:19:04 +00:00
Sergey Miryanov
3a7f17c7e2
gh-130790: Remove references about unicode's readiness from comments ( #130801 )
2025-03-03 19:18:09 +00:00
Hugo Beauzée-Luyssen
214562ed4d
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`.
2025-03-02 09:56:49 +00:00
Pablo Galindo Salgado
e06bebb87e
gh-130618: Fix parser error when using lambdas inside f-strings ( #130638 )
2025-02-27 15:51:17 +00:00
Mark Shannon
014223649c
GH-130396: Use computed stack limits on linux (GH-130398)
...
* Implement C recursion protection with limit pointers for Linux, MacOS and Windows
* Remove calls to PyOS_CheckStack
* Add stack protection to parser
* Make tests more robust to low stacks
* Improve error messages for stack overflow
2025-02-25 09:24:48 +00:00
Petr Viktorin
ef29104f7d
GH-91079: Revert "GH-91079: Implement C stack limits using addresses, not counters. (GH-130007)" for now (GH130413)
...
Revert "GH-91079: Implement C stack limits using addresses, not counters. (GH-130007)" for now
Unfortunatlely, the change broke some buildbots.
This reverts commit 2498c22fa0
.
2025-02-24 11:16:08 +01:00
Mark Shannon
2498c22fa0
GH-91079: Implement C stack limits using addresses, not counters. (GH-130007)
...
* Implement C recursion protection with limit pointers
* Remove calls to PyOS_CheckStack
* Add stack protection to parser
* Make tests more robust to low stacks
* Improve error messages for stack overflow
2025-02-19 11:44:57 +00:00
Sergey Miryanov
bcc9a5dddb
gh-129515: Clarify syntax error messages for conditional expressions ( #129880 )
...
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-02-18 21:43:19 +00:00
Irit Katriel
c9b1bf302c
gh-130139: always check ast node type in ast.parse() with ast input ( #130140 )
2025-02-16 13:32:39 +00:00
Pablo Galindo Salgado
3bd3e09588
gh-125331: Allow the parser to activate future imports on the fly ( #125482 )
2025-02-14 04:54:56 +00:00
Pablo Galindo Salgado
6fb5138776
gh-88535: Improve syntax error for wrongly closed strings ( #26633 )
2025-02-13 01:30:20 +00:00
Pablo Galindo Salgado
56eda25633
gh-116042: Fix location for SyntaxErrors of invalid escapes in the tokenizer ( #116049 )
2025-02-13 01:07:37 +00:00
Victor Stinner
3bebe46d34
gh-128911: Add PyImport_ImportModuleAttr() function ( #128912 )
...
Add PyImport_ImportModuleAttr() and
PyImport_ImportModuleAttrString() functions.
* Add unit tests.
* Replace _PyImport_GetModuleAttr()
with PyImport_ImportModuleAttr().
* Replace _PyImport_GetModuleAttrString()
with PyImport_ImportModuleAttrString().
* Remove "pycore_import.h" includes, no longer needed.
2025-01-30 11:17:29 +00:00
Victor Stinner
0093a31273
gh-119182: Use public PyUnicodeWriter in Python-ast.c ( #129209 )
...
Replace the private _PyUnicodeWriter API with the public
PyUnicodeWriter API.
Use PyUnicodeWriter_WriteRepr() in ast_repr_list().
2025-01-23 00:57:37 +00:00
Pablo Galindo Salgado
60a3a0dd6f
gh-124363: Treat debug expressions in f-string as raw strings ( #128399 )
...
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2025-01-22 16:24:54 +00:00
Tomas R.
767cf70844
gh-129093: Fix f-string debug text sometimes getting cut off when expression contains `!` ( #129159 )
2025-01-22 00:26:37 +00:00
Umar Butler
8d8b854824
gh-128016: Improved invalid escape sequence warning message ( #128020 )
2025-01-15 18:00:54 +01:00
qqwqqw689
c810ed7c8e
gh-126469: remove unnecessary error-checking branch in `lexer.c` ( #126473 )
2025-01-01 22:11:29 +00:00
Bénédikt Tran
94639f6b71
gh-126240: handle `NULL` returned by `_Py_asdl_expr_seq_new` ( #126241 )
...
check return value of `_Py_asdl_expr_seq_new`
2024-10-31 17:24:07 +03:00
sobolevn
b2eaa75b17
gh-126105: Fix crash in `ast` module, when `._fields` is deleted ( #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).
2024-10-29 17:42:48 +02:00
Victor Stinner
4a943c3251
gh-125196: Use PyUnicodeWriter in parser ( #125271 )
...
Replace the private _PyUnicodeWriter API with the public
PyUnicodeWriter API in _PyPegen_concatenate_strings().
2024-10-12 09:28:34 +02:00
Sam Gross
427dcf24de
gh-125268: Use static string for "1e309" in AST ( #125272 )
...
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.
2024-10-10 16:21:29 -04:00
Victor Stinner
b9a8ca0a6a
gh-115754: Use Py_GetConstant(Py_CONSTANT_EMPTY_STR) ( #125194 )
...
Replace PyUnicode_New(0, 0), PyUnicode_FromString("")
and PyUnicode_FromStringAndSize("", 0)
with Py_GetConstant(Py_CONSTANT_EMPTY_STR).
2024-10-09 17:15:23 +02:00
Victor Stinner
6a39e96ab8
gh-115754: Use Py_GetConstant(Py_CONSTANT_EMPTY_BYTES) ( #125195 )
...
Replace PyBytes_FromString("") and PyBytes_FromStringAndSize("", 0)
with Py_GetConstant(Py_CONSTANT_EMPTY_BYTES).
2024-10-09 17:12:11 +02:00
Tomas R.
a1be83dae3
gh-125010: Fix `use-after-free` in AST `repr()` ( #125015 )
2024-10-06 12:46:03 -07:00
Rigel Di Scala
39c859f6ff
gh-122951: Simplify the grammar of the assignment rule ( #124998 )
2024-10-06 11:55:56 +02:00
Victor Stinner
6c7d5c6415
gh-111178: Fix function signatures in Python-ast.c ( #124942 )
2024-10-04 11:59:08 +02:00
efimov-mikhail
1f9025a4e7
gh-124889: Remove redundant artificial rules in PEG parser ( #124893 )
...
Cache in C PEG-generator reworked:
we save artificial rules in cache by Node string representation as a key instead of Node object itself.
As a result total count of artificial rules in parsers.c is lowered from 283 to 170.
More natural number ordering is used for the names of artificial rules.
Auxiliary method CCallMakerVisitor._generate_artificial_rule_call is added.
Its purpose is abstracting work with artificial rules cache.
Explicit using of "is_repeat1" kwarg is added to visit_Repeat0 and visit_Repeat1 methods.
Its slightly improve code readabitily.
2024-10-03 13:58:56 +01:00
Tomas R
21d2a9ab2f
gh-116022: Improve `repr()` of AST nodes ( #117046 )
...
Co-authored-by: AN Long <aisk@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-09-18 10:28:22 -07:00
Victor Stinner
f9fa6ba4f8
gh-124064: Fix -Wconversion warnings in Parser/string_parser.c ( #124204 )
...
Fix integer overflow check in decode_unicode_with_escapes(): use
PY_SSIZE_T_MAX instead of SIZE_MAX.
2024-09-18 19:10:56 +02:00
Victor Stinner
3aff1d0260
gh-124064: Fix -Wconversion warnings in Parser/pegen.c ( #124181 )
2024-09-17 15:58:43 +00:00
Sam Gross
0c080d7c77
gh-123321: Make Parser/myreadline.c locking safe in free-threaded build ( #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.
2024-09-06 15:07:08 -04:00
Bar Harel
a4562fedad
gh-123321: Fix Parser/myreadline.c to prevent a segfault during a multi-threaded race ( #123323 )
2024-09-04 17:21:30 +02:00
sobolevn
23f159ae71
gh-123562: Improve `SyntaxError` message for `case ... as a.b` ( #123563 )
2024-09-02 13:11:44 +02:00
sobolevn
e451a8937d
gh-123440: Improve error message for `except as` used with not a name ( #123442 )
2024-08-30 17:21:59 +01:00
Pablo Galindo Salgado
adc5190014
gh-123229: Fix valgrind warning by initializing the f-string buffers to 0 in the tokenizer ( #123263 )
...
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
2024-08-23 12:33:45 +00:00
Lysandros Nikolaou
ce0d66c8d2
gh-122581: Avoid data races when collecting parser statistics ( #122694 )
2024-08-06 13:29:57 +02:00
Pablo Galindo Salgado
db2d8b6db1
gh-122300: Preserve AST nodes for format specifiers with single elements ( #122308 )
2024-07-26 16:29:41 +00:00
Serhiy Storchaka
6c09b8de5c
gh-122270: Fix typos in the Py_DEBUG macro name (GH-122271)
2024-07-25 14:04:22 +03:00
Xie Yanbo
2a5d1eb707
Fix typos in comments and exception message ( #122147 )
2024-07-23 14:34:14 +05:30
Pablo Galindo Salgado
2009e25e26
gh-122026: Fix identification of mismatched parentheses inside f-strings ( #122028 )
2024-07-19 19:08:08 +02:00
Serhiy Storchaka
1a0c7b9ba4
gh-121905: Consistently use "floating-point" instead of "floating point" (GH-121907)
2024-07-19 08:06:02 +00:00
Pablo Galindo Salgado
c46d64e0ef
gh-121130: Fix f-string format specifiers with debug expressions ( #121150 )
2024-07-16 19:57:22 +01:00
Jelle Zijlstra
58e8cf2bb6
gh-121332: Make AST node constructor check _attributes instead of hardcoding attributes ( #121334 )
2024-07-11 14:34:53 +00:00
Bénédikt Tran
9728ead361
gh-121141: add support for `copy.replace` to AST nodes ( #121162 )
2024-07-03 20:10:54 -07:00
Victor Stinner
769aea3329
gh-120155: Fix Coverity issue in parse_string() ( #120997 )
2024-06-25 17:53:24 +01:00
Jelle Zijlstra
42b2c9d78d
gh-120108: Fix deepcopying of AST trees with .parent attributes ( #120114 )
2024-06-25 08:12:11 -07:00
Lysandros Nikolaou
348184845a
gh-120956: Avoid comparison of int to Py_ssize_t in parser ( #120959 )
2024-06-24 18:13:02 +02:00