Commit graph

9798 commits

Author SHA1 Message Date
Neil Schemenauer
e414a2d81c
gh-127266: avoid data races when updating type slots (gh-131174)
In the free-threaded build, avoid data races caused by updating type slots
or type flags after the type was initially created.  For those (typically
rare) cases, use the stop-the-world mechanism.  Remove the use of atomics
when reading or writing type flags.  The use of atomics is not sufficient to
avoid races (since flags are sometimes read without a lock and without
atomics) and are no longer required.
2025-04-28 20:28:44 +00:00
Eric Snow
606003ffa9
gh-132775: Add _PyBytes_GetXIData() (gh-133101)
This is the base for several other XIData wrappers, like pickle and marshal. It is essentially a refactor of the existing bytes XIData code.
2025-04-28 12:52:36 -06:00
Eric Snow
fe462f5a91
gh-132775: Drop PyUnstable_InterpreterState_GetMainModule() (gh-132978)
We replace it with _Py_GetMainModule(), and add _Py_CheckMainModule(), but both in the internal-only C-API.  We also add _PyImport_GetModulesRef(), which is the equivalent of _PyImport_GetModules(), but which increfs before the lock is released.

This is used by a later change related to pickle and handling __main__.
2025-04-28 12:46:22 -06:00
Eric Snow
6f04325992
gh-132775: Cleanup Related to crossinterp.c Before Further Changes (gh-132974)
This change consists of adding tests and moving code around, with some renaming thrown in.
2025-04-28 11:55:15 -06:00
Jelle Zijlstra
58567cc18c
gh-132952: Speed up startup by importing _io instead of io (#132957) 2025-04-28 08:38:56 -07:00
Jelle Zijlstra
922049b613
gh-130907: Treat all module-level annotations as conditional (#131550) 2025-04-28 06:10:28 -07:00
Bénédikt Tran
af3f6fcb7e
gh-127604: ensure -ldl is passed only once to the linker (#133071) 2025-04-28 11:55:02 +02:00
Emma Smith
20be6ba61a
gh-132983: Introduce compression package and move _compression module (GH-133018)
* Introduces `compression` package for https://peps.python.org/pep-0784/

This commit introduces the `compression` package, specified in PEP 784
to re-export the `lzma`, `bz2`, `gzip`, and `zlib` modules. Introduction
of `compression.zstd` will be completed in a future commit once the
`_zstd` module is merged.

This commit also moves the `_compression` private module to
`compression._common._streams`.

* Re-exports existing module docstrings.
2025-04-27 14:41:30 -07:00
Nadeshiko Manju
614d79231d
gh-131798: JIT - Use sym_new_type instead of sym_new_not_null for _BUILD_STRING, _BUILD_SET (GH-132564)
Signed-off-by: Manjusaka <me@manjusaka.me>
2025-04-27 20:30:28 +08:00
Tomas R.
5e96e4fca8
gh-131798: JIT: Propagate the result in _BINARY_OP_SUBSCR_TUPLE_INT (GH-133003) 2025-04-27 02:47:55 +08:00
Serhiy Storchaka
632524a5cb
gh-132987: Support __index__() for "k" and "K" formats in PyArg_Parse (GH-132988) 2025-04-26 17:14:18 +03:00
Bénédikt Tran
ca12a744ab
gh-132781: fix refleaks in crossinterp_exceptions.h post gh-132782 (#132989) 2025-04-26 12:14:14 +02:00
Eric Snow
8a4d4f37ab
gh-132781: Make NotShareableError a TypeError Subclass (gh-132973)
It was a subclass of ValueError. However, shareability is a feature of types, not values.
2025-04-25 21:10:43 +00:00
Eric Snow
cd9536a087
gh-132781: Cleanup Code Related to NotShareableError (gh-132782)
The following are added to the internal C-API:

* _PyErr_FormatV()
* _PyErr_SetModuleNotFoundError()
* _PyXIData_GetNotShareableErrorType()
* _PyXIData_FormatNotShareableError()

We also drop _PyXIData_lookup_context_t and _PyXIData_GetLookupContext().
2025-04-25 14:43:38 -06:00
Diego Russo
4c20f46fa0
gh-131798: JIT: Narrow the return type of _CALL_LEN to int (#132940)
Reduce unnecessary guards whenever `len()` is called and used
after.

Co-authored-by: Max Bernstein <tekknolagi@gmail.com>
2025-04-26 02:57:42 +08:00
Eric Snow
2a28b21a51
gh-132776: Revert Moving memoryview XIData Code to memoryobject.c (gh-132960)
This is a partial revert of gh-132821.  It resolves the refleak introduced by that PR.
2025-04-25 16:43:50 +00:00
Pablo Galindo Salgado
622176513e
gh-132950: Check for Py_SUPPORTS_REMOTE_DEBUG in sys.is_remote_debug_enabled (#132959) 2025-04-25 16:38:48 +00:00
Victor Stinner
ac5424d6a9
gh-107954: Add audit event to PyConfig_Set() (#132958) 2025-04-25 18:30:39 +02:00
Victor Stinner
070d866567
gh-107954: Allow setting cpu_count in PyConfig_Set() (#132954)
* gh-107954: Allow setting cpu_count in PyConfig_Set()

* Update the doc
2025-04-25 18:29:55 +02:00
Victor Stinner
17718b0503
gh-91048: Fix _testexternalinspection.c on FreeBSD (#132945) 2025-04-25 14:57:01 +00:00
Pablo Galindo Salgado
e8cf3a1a64
gh-91048: Refactor _testexternalinspection and add Windows support (#132852) 2025-04-25 14:12:16 +01:00
Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్ రెడ్డి)
8783cec9b6
gh-129027: Raise DeprecationWarning for sys._clear_type_cache (#129043)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-04-25 15:01:48 +03:00
Bénédikt Tran
3fa024dec3
gh-132909: handle overflow for 'K' format in do_mkvalue (#132911) 2025-04-25 11:02:57 +00:00
Victor Stinner
c292f7f563
gh-127604: Only define dump_pointer() if CAN_C_BACKTRACE (#132897) 2025-04-25 09:28:34 +02:00
Pablo Galindo Salgado
22c9886c8e
gh-131591: Implement PEP 768 support for FAT mac binaries and 32 bit binaries (#132892)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
2025-04-25 01:58:19 +01:00
Eric Snow
e54e828852
gh-132776: Cleanup for XIBufferViewType (gh-132821)
* add notes
* rename XIBufferViewObject to xibufferview
* move memoryview XIData code to memoryobject.c
2025-04-24 18:25:29 -06:00
Tomas R.
08e3389e8c
GH-131798: Split up and optimize CALL_TUPLE_1 in the JIT (GH-132851) 2025-04-24 15:55:03 -07:00
Tomas R.
0a387b311e
GH-131798: Split up and optimize CALL_STR_1 in the JIT (GH-132849) 2025-04-24 12:54:46 -07:00
Matt Wozniski
a94c7528b5
gh-132859: Run debugger scripts in their own namespaces (#132860)
Run debugger scripts in their own namespaces

Previously scripts injected by `sys.remote_exec` were run with the
globals of the `__main__` module. Instead, run each injected script
with an empty set of globals. If someone really wants to use the
`__main__` module's namespace, they can always `import __main__`.
2025-04-23 23:40:24 +00:00
Victor Stinner
402dba2928
gh-127604: Replace dprintf() with _Py_write_noraise() (#132854) 2025-04-23 20:02:25 +00:00
Pablo Galindo Salgado
99b13775da
gh-131591: Check for remote debug in PyErr_CheckSignals (#132853)
For the same reasons as running the GC, this will allow sections that
run in native code for long periods without executing bytecode to also
run the remote debugger protocol without having to wait until bytecode
is executed

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
2025-04-23 20:59:41 +01:00
Pablo Galindo Salgado
1007aab133
gh-127604: Allow faulthandler to dumpC stack on MacOS (#132841) 2025-04-23 18:23:24 +01:00
Ken Jin
6430c634da
gh-132758: Fix tail call and pystats builds (GH-132759) 2025-04-23 18:17:35 +08:00
Tomas R.
a6a3dbb7db
GH-131798: JIT: Split CALL_TYPE_1 into several uops (GH-132419) 2025-04-22 09:30:38 -07:00
Jelle Zijlstra
01317bb449
gh-132479: Fix crash with multiple comprehensions in annotations (#132778) 2025-04-21 13:49:59 -07:00
Sam Gross
da53660f35
gh-131586: Avoid refcount contention in context managers (gh-131851)
This avoid reference count contention in the free threading build
when calling special methods like `__enter__` and `__exit__`.
2025-04-21 15:54:25 -04:00
Peter Bierma
8dfa840773
gh-127604: Add C stack dumps to faulthandler (#128159) 2025-04-21 20:48:02 +01:00
Brandt Bucher
4f7f72ce34
GH-130415: Improve the JIT's unneeded uop removal pass (GH-132333) 2025-04-21 09:58:55 -07:00
Bénédikt Tran
427e7fc099
gh-132399: ensure correct alignment of PyInterpreterState (#132428) 2025-04-19 11:03:06 +02:00
Bénédikt Tran
8a9c6c4d16
gh-128398: improve error messages when incorrectly using with and async with (#132218)
Improve the error message with a suggestion when an object supporting the synchronous
(resp. asynchronous) context manager protocol is entered using `async with` (resp. `with`)
instead of `with` (resp. `async with`).
2025-04-19 10:44:01 +02:00
Pablo Galindo Salgado
c9a855a9e0
gh-131591: Execute the source and not the file to avoid locking it in Windows (#132712)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
2025-04-19 00:38:12 +00:00
Kumar Aditya
7fd708b727
gh-132685: fix thread safety of PyMember_GetOne with _Py_T_OBJECT (#132690) 2025-04-18 21:03:42 +05:30
Brandt Bucher
40ae88988c
GH-131498: Replace single-element arrays with scalars in bytecodes.c (GH-132615) 2025-04-18 07:16:28 -07:00
Bénédikt Tran
379352620c
gh-132097: use a macro for semantically casting function pointers (#132406) 2025-04-18 12:24:34 +02:00
Kumar Aditya
f3d877a27a
gh-132643: use atomic load for dict in specializer (#132653) 2025-04-18 15:06:27 +05:30
Adam Turner
ea23c897cd
Remove duplicate includes: Python/importdl.c (#132623) 2025-04-18 02:49:19 +01:00
Alper
22830103e5
gh-131173: Improve exception handling during take_ownership processing (#132620)
Save and restore exceptions during take_ownership processing to preserve
exceptions currently being raised.

Co-authored-by: alperyoney <alperyoney@fb.com>
2025-04-17 13:38:34 -07:00
Bartosz Sławecki
954b2cf031
gh-130070: Fix exec(<string>, closure=<non-None>) unexpected path (#130071)
Fixed an assertion error (so, it could be reproduced only in builds with assertions enabled)
for `exec` when the `source` argument is a string and the `closure` argument is not `None`.

Co-authored-by: sobolevn <mail@sobolevn.me>
2025-04-17 10:14:55 +03:00
Adam Turner
d7df7815f5
Remove duplicate includes: Python/ast_opt.c (#132621) 2025-04-17 10:10:01 +03:00
Nadeshiko Manju
b9e88ff4cb
gh-131798: Use sym_new_type instead of sym_new_not_null for _BUILD_LIST, _BUILD_SLICE, and _BUILD_MAP (GH-132434)
---------

Signed-off-by: Manjusaka <me@manjusaka.me>
2025-04-17 01:17:48 +08:00