Commit Graph

9139 Commits

Author SHA1 Message Date
Mark Shannon c87b0e4a46
GH-124284: Add stats for refcount operations on immortal objects (GH-124288) 2024-09-23 19:10:55 +01:00
AN Long 1a577729e3
gh-111513: Improve datetime.fromtimestamp's error message (#124249) 2024-09-20 14:42:43 +02:00
Petr Viktorin aee219f455
gh-123880: Allow recursive import of single-phase-init modules (GH-123950)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: Brett Cannon <brett@python.org>
2024-09-20 10:27:34 +02:00
luk1337 7331d0f70b
gh-124160: Pass main_tstate to update_global_state_for_extension() (#124164) 2024-09-19 21:35:20 +05:30
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
Irit Katriel aba42c0b54
gh-123969: refactor _PyErr_RaiseSyntaxError and _PyErr_EmitSyntaxWarning out of compiler (#123972) 2024-09-16 15:05:00 +01:00
Irit Katriel 9aa1f60e2d
gh-124058: remove _PyCompile_IsNestedScope, roll it into _PyCompile_IsInteractive (#124061) 2024-09-16 06:58:18 -07:00
Sam Gross b02301fa5a
gh-124068: Fix reference leak with generators in the free-threaded build (#124069)
If the generator is already cleared, then most fields in the
generator's frame are not valid other than f_executable. The invalid
fields may contain dangling pointers and should not be used.
2024-09-13 22:02:27 -04:00
Ken Jin 8810e286fa
gh-121459: Deferred LOAD_GLOBAL (GH-123128)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Sam Gross <655866+colesbury@users.noreply.github.com>
2024-09-14 00:23:51 +08:00
Irit Katriel a9594a34c6
gh-124022: Fix bug where class docstring is removed in interactive mode (#124023)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-09-13 14:06:06 +00:00
Irit Katriel 6e06e01881
gh-124019: do not call codegen_annotations_in_scope if there are no annotations (#124020) 2024-09-12 20:24:15 +01:00
Irit Katriel 8145ebea58
gh-124013: remove _PyCompile_IsTopLevelAwait (#124014) 2024-09-12 19:58:32 +01:00
Sam Gross b2afe2aae4
gh-123923: Defer refcounting for `f_executable` in `_PyInterpreterFrame` (#123924)
Use a `_PyStackRef` and defer the reference to `f_executable` when
possible. This avoids some reference count contention in the common case
of executing the same code object from multiple threads concurrently in
the free-threaded build.
2024-09-12 12:37:06 -04:00
Mark Shannon 4ed7d1d6ac
GH-123996: Explicitly mark 'self_or_null' as an array of size 1 to ensure that it is kept in memory for calls (GH-124003) 2024-09-12 15:32:45 +01:00
Irit Katriel e07154fd1e
gh-123958: apply docstring removal optimization in ast_opt instead of codegen (#123959) 2024-09-11 17:02:28 +00:00
Irit Katriel a2d0818c85
gh-123881: make compiler add the .generic_base base class without constructing AST nodes (#123883) 2024-09-10 16:16:00 +00:00
Tushar Sadhwani 3597642ed5
gh-122239: Add actual count in unbalanced unpacking error message when possible (#122244) 2024-09-10 16:07:30 +01:00
Victor Stinner fb1b51a58d
gh-123892: Add "_wmi" to sys.stdlib_module_names (#123893) 2024-09-10 09:54:17 +00:00
Irit Katriel 1a9d8917a3
gh-121404: split compile.c into compile.c and codegen.c (#123651) 2024-09-09 18:21:51 +01:00
Peter Bierma 84ad264ce6
gh-123275: Support `-Xgil=1` and `PYTHON_GIL=1` on non-free-threaded builds (gh-123276) 2024-09-06 08:53:47 +09:00
Savannah Ostrowski 1fbc118c5d
GH-123545: Remove duplicate Py_DECREF when handling _PyOptimizer_Optimize errors (GH-123546) 2024-09-05 10:56:07 -07:00
Victor Stinner 0d6b6e34a2
gh-107954, PEP 741: Add PyInitConfig_AddModule() function (#123668) 2024-09-04 11:41:57 +00:00
Victor Stinner b423ae6b08
gh-107954, PEP 741: Adjust Python initialization config (#123663)
Setting dev_mode to 1 in an isolated configuration now enables also
faulthandler.

Moreover, setting "module_search_paths" option with
PyInitConfig_SetStrList() now sets "module_search_paths_set" to 1.
2024-09-04 10:58:32 +00:00
Sergey B Kirpichev 6822cb23c6
gh-121804: always show error location for SyntaxError's in basic repl (#123202) 2024-09-03 12:37:29 +00:00
Victor Stinner ef9d54703f
gh-107954, PEP 741: Add PyInitConfig C API (#123502)
Add Doc/c-api/config.rst documentation.
2024-09-03 12:33:49 +00:00
Victor Stinner 33b790978d
gh-107954, PEP 741: Add PyConfig_Get()/Set() functions (#123472)
Add PyConfig_Get(), PyConfig_GetInt(), PyConfig_Set() and
PyConfig_Names() functions to get and set the current runtime Python
configuration.

Add visibility and "sys spec" to config and preconfig specifications.

_PyConfig_AsDict() now converts PyConfig.xoptions as a dictionary.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-09-02 23:25:08 +02:00
Irit Katriel fbb26f067a
gh-121404: enforce that codegen doesn't access compiler, and compiler doesn't use codegen macros (#123575) 2024-09-02 17:23:39 +00:00
Petr Viktorin 57c471a688
gh-123091: Use more _Py_IsImmortalLoose() (GH-123602)
Switch more _Py_IsImmortal(...) assertions to _Py_IsImmortalLoose(...)

The remaining calls to _Py_IsImmortal are in free-threaded-only code,
initialization of core objects, tests, and guards that fall back to
code that works with mortal objects.
2024-09-02 18:17:48 +02:00
Victor Stinner f1a0d96f41
gh-123091: Use _Py_IsImmortalLoose() (#123511)
Use _Py_IsImmortalLoose() in bytesobject.c, typeobject.c
and ceval.c.
2024-09-02 14:25:19 +02:00
sobolevn 91b7f2e7f6
gh-123553: Fix compile warning in `compile.c` (#123578) 2024-09-01 15:43:45 +00:00
Kirill Podoprigora 084e0f35d1
gh-123553: Fix compiler warning in `Python/compile.c` (#123554) 2024-09-01 06:29:34 +00:00
Irit Katriel 6bfbfc6af3
gh-121404: rearrange code in compile.c so that codegen functions come first and compiler functions second (#123510) 2024-08-30 22:54:42 +01:00
Victor Stinner d8e69b2c1b
gh-122854: Add Py_HashBuffer() function (#122855) 2024-08-30 15:42:27 +00:00
Serhiy Storchaka 32c7dbb2bc
gh-121485: Always use 64-bit integers for integers bits count (GH-121486)
Use 64-bit integers instead of platform specific size_t or Py_ssize_t
to represent the number of bits in Python integer.
2024-08-30 08:13:24 +03:00
Irit Katriel 61bef6245c
gh-123142: fix too wide source location of GET_ITER/GET_AITER (#123420) 2024-08-28 17:11:52 +01:00
Bogdan Romanyuk be083cee34
gh-123344: Add missing ast optimizations for PEP 696 (#123377)
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-08-28 06:38:56 -07:00
Pieter Eendebak 7e38e6745d
gh-123271: Make builtin zip method safe under free-threading (#123272)
The `zip_next` function uses a common optimization technique for methods
that generate tuples. The iterator maintains an internal reference to
the returned tuple. When the method is called again, it checks if the
internal tuple's reference count is 1. If so, the tuple can be reused.
However, this approach is not safe under the free-threading build:
after checking the reference count, another thread may perform the same
check and also reuse the tuple. This can result in a double decref on
the items of the replaced tuple and a double incref (memory leak) on
the items of the tuple being set.

This adds a function, `_PyObject_IsUniquelyReferenced` that
encapsulates the stricter logic necessary for the free-threaded build:
the internal tuple must be owned by the current thread, have a local
refcount of one, and a shared refcount of zero.
2024-08-27 15:22:43 -04:00
Irit Katriel d24d1c986d
gh-121404: split compiler_nameop into a codegen part and a compiler part (#123398) 2024-08-27 16:57:31 +01:00
Mark Shannon f49a91648a
GH-117759: Document incremental GC (GH-123266)
* Update what's new

* Update gc module docs and fix inconsistency in gc.get_objects
2024-08-27 15:23:39 +01:00
Irit Katriel da4302699f
gh-121404: compiler_visit_* --> codegen_visit_* (#123382) 2024-08-27 11:32:24 +00:00
Mark Shannon 54a05a4600
GH-123232: Factor BINARY_SLICE and STORE_SLICE to handle stats properly for tier 2. (GH-123381) 2024-08-27 10:49:39 +01:00
Anthony Shaw 86f06cb3fb
Remove comment from pystate created in 2003 (#123259) 2024-08-24 20:36:42 +00:00
Sam Gross 556e855684
gh-117376: Make `Py_DECREF` a macro in ceval.c in free-threaded build (#122975)
`Py_DECREF` and `PyStackRef_CLOSE` are now implemented as macros in the
free-threaded build in ceval.c. There are two motivations;

 * MSVC has problems inlining functions in ceval.c in the PGO build.

 * We will want to mark escaping calls in order to spill the stack
   pointer in ceval.c and we will want to do this around `_Py_Dealloc`
   (or `_Py_MergeZeroLocalRefcount` or `_Py_DecRefShared`), not around
   the entire `Py_DECREF` or `PyStackRef_CLOSE` call.
2024-08-23 15:36:14 -04:00
Kirill Podoprigora 67f2c84bff
gh-123205: `Python/bytecodes.c`: Fix compiler warning (#123206)
Fix MSVC warning "conversion from '__int64' to 'int'"
2024-08-23 15:35:25 -04:00
Irit Katriel bf1b5d323b
gh-121404: more compiler_* -> codegen_*, class_body and comprehensions (#123262) 2024-08-23 19:53:15 +01:00
Mark Shannon 7cd3aa42f0
GH-122298: Restore printing of GC stats (GH-123261) 2024-08-23 16:39:08 +01:00
Mark Shannon 0b0f7befad
GH-123232: Fix "not specialized" stats (GH-123236) 2024-08-23 10:46:03 +01:00
Irit Katriel 5fce482c9a
gh-121404: compiler_annassign --> codegen_annassign (#123245) 2024-08-23 10:39:42 +01:00
Mark Shannon 5d3201fe3f
GH-123040: Specialize shadowed `LOAD_ATTR`. (GH-123219) 2024-08-23 10:22:35 +01:00
Donghee Na 297f2e093e
gh-123083: Fix a potential use-after-free in ``STORE_ATTR_WITH_HINT`` (gh-123092) 2024-08-22 23:49:09 +09:00