summaryrefslogtreecommitdiffstats
path: root/Modules
Commit message (Collapse)AuthorAgeFilesLines
* gh-111926: Make weakrefs thread-safe in free-threaded builds (#117168)mpage2024-04-086-52/+38
| | | | | | | | | Most mutable data is protected by a striped lock that is keyed on the referenced object's address. The weakref's hash is protected using the weakref's per-object lock. Note that this only affects free-threaded builds. Apart from some minor refactoring, the added code is all either gated by `ifdef`s or is a no-op (e.g. `Py_BEGIN_CRITICAL_SECTION`).
* gh-111140: PyLong_From/AsNativeBytes: Take *flags* rather than just ↵Steve Dower2024-04-051-7/+7
| | | | *endianness* (GH-116053)
* gh-117435: Make `SemLock` thread-safe in free-threaded build (#117436)Sam Gross2024-04-042-9/+37
| | | | Use critical sections to make acquire, release, and _count thread-safe without the GIL.
* gh-116968: Reimplement Tier 2 counters (#117144)Guido van Rossum2024-04-041-0/+6
| | | | | | | | | | | | Introduce a unified 16-bit backoff counter type (``_Py_BackoffCounter``), shared between the Tier 1 adaptive specializer and the Tier 2 optimizer. The API used for adaptive specialization counters is changed but the behavior is (supposed to be) identical. The behavior of the Tier 2 counters is changed: - There are no longer dynamic thresholds (we never varied these). - All counters now use the same exponential backoff. - The counter for ``JUMP_BACKWARD`` starts counting down from 16. - The ``temperature`` in side exits starts counting down from 64.
* gh-117267: Ensure DirEntry.stat().st_ctime still contains creation time ↵Steve Dower2024-04-031-0/+4
| | | | during deprecation period (GH-117354)
* gh-114329: Fix PyList_GetItemRef() limited C API definition (#117520)Victor Stinner2024-04-035-4/+10
|
* gh-116168: Remove extra `_CHECK_STACK_SPACE` uops (#117242)Peter Lazorchak2024-04-031-0/+12
| | | This merges all `_CHECK_STACK_SPACE` uops in a trace into a single `_CHECK_STACK_SPACE_OPERAND` uop that checks whether there is enough stack space for all calls included in the entire trace.
* gh-76785: Raise InterpreterError, Not RuntimeError (gh-117489)Eric Snow2024-04-031-4/+4
| | | | | I had meant to switch everything to InterpreterError when I added it a while back. At the time I missed a few key spots. As part of this, I've added print-the-exception to _PyXI_InitTypes() and fixed an error case in `_PyStaticType_InitBuiltin().
* GH-114847: Raise FileNotFoundError when getcwd() returns '(unreachable)' ↵Barney Gale2024-04-031-0/+14
| | | | | | | | | (#117481) On Linux >= 2.6.36 with glibc < 2.27, `getcwd()` can return a relative pathname starting with '(unreachable)'. We detect this and fail with ENOENT, matching new glibc behaviour. Co-authored-by: Petr Viktorin <encukou@gmail.com>
* gh-91565: Update issue tracker URL in error message. (#117450)Ezio Melotti2024-04-031-2/+2
| | | | | * Update issue tracker URL in commit message. * Also update issue tracker URL in comment.
* gh-76785: Consolidate Some Interpreter-related Testing Helpers (gh-117485)Eric Snow2024-04-022-250/+249
| | | This eliminates the duplication of functionally identical helpers in the _testinternalcapi and _xxsubinterpreters modules.
* gh-76785: Add PyInterpreterConfig Helpers (gh-117170)Eric Snow2024-04-021-60/+146
| | | These helpers make it easier to customize and inspect the config used to initialize interpreters. This is especially valuable in our tests. I found inspiration from the PyConfig API for the PyInterpreterConfig dict conversion stuff. As part of this PR I've also added a bunch of tests.
* gh-117440: Make `syslog` thread-safe in free-threaded builds (#117441)Sam Gross2024-04-022-5/+19
| | | Use critical sections to protect access to the syslog module.
* GH-115776: Embed the values array into the object, for "normal" Python ↵Mark Shannon2024-04-023-6/+21
| | | | objects. (GH-116115)
* gh-94808: Fix refcounting in PyObject_Print tests (GH-117421)Petr Viktorin2024-04-011-0/+4
|
* gh-117142: ctypes: Unify meta tp slot functions (GH-117143)neonene2024-04-013-73/+46
| | | | | | | Integrates the following ctypes meta tp slot functions: * `CDataType_traverse()` into `CType_Type_traverse()`. * `CDataType_clear()` into `CType_Type_clear()`. * `CDataType_dealloc()` into `CType_Type_dealloc()`. * `CDataType_repeat()` into `CType_Type_repeat()`.
* gh-94808:Improve coverage of PyObject_Print (GH-98749)MonadChains2024-04-014-1/+138
|
* gh-117142: ctypes: Migrate global vars to module state (GH-117189)neonene2024-03-296-222/+235
|
* gh-117310: Remove extra DECREF on "no ciphers" error path in ↵Gregory P. Smith2024-03-281-1/+0
| | | | | | | | | | `_ssl._SSLContext` constructor (#117309) Remove extra self DECREF on ssl "no ciphers" error path. This doesn't come up in practice because nobody links against a broken OpenSSL library that provides nothing.
* gh-115627: Fix PySSL_SetError handling SSL_ERROR_SYSCALL (GH-115628)yevgeny hong2024-03-261-30/+18
| | | | | | | | | | | | | | | | | Python 3.10 changed from using SSL_write() and SSL_read() to SSL_write_ex() and SSL_read_ex(), but did not update handling of the return value. Change error handling so that the return value is not examined. OSError (not EOF) is now returned when retval is 0. According to *recent* man pages of all functions for which we call PySSL_SetError, (in OpenSSL 3.0 and 1.1.1), their return value should be used to determine whether an error happened (i.e. if PySSL_SetError should be called), but not what kind of error happened (so, PySSL_SetError shouldn't need retval). To get the error, we need to use SSL_get_error. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Petr Viktorin <encukou@gmail.com>
* gh-99108: Refresh HACL*; update modules accordingly; fix namespacing (GH-117237)Jonathan Protzenko2024-03-2621-1813/+1567
| | | Pulls in a new update from https://github.com/hacl-star/hacl-star and fixes our C "namespacing" done by `Modules/_hacl/refresh.sh`.
* gh-87193: Support bytes objects with refcount > 1 in _PyBytes_Resize() ↵Serhiy Storchaka2024-03-254-1/+58
| | | | | (GH-117160) Create a new bytes object and destroy the old one if it has refcount > 1.
* gh-112383: teach dis how to interpret ENTER_EXECUTOR (#117171)Irit Katriel2024-03-233-22/+84
|
* gh-91227: Ignore ERROR_PORT_UNREACHABLE in proactor recvfrom() (#32011)Erik Soma2024-03-231-0/+1
|
* GH-117108: Change the size of the GC increment to about 1% of the total heap ↵Mark Shannon2024-03-221-1/+1
| | | | size. (GH-117120)
* gh-113024: C API: Add PyObject_GenericHash() function (GH-113025)Serhiy Storchaka2024-03-222-1/+12
|
* gh-117068: Remove useless code in bytesio.c:resize_buffer() (GH-117069)NGRsoftlab2024-03-221-3/+0
| | | Co-authored-by: i.khabibulin <i.khabibulin@ngrsoftlab.ru>
* gh-105716: Fix _PyInterpreterState_IsRunningMain() For Embedders (gh-117140)Eric Snow2024-03-221-2/+20
| | | | | When I added _PyInterpreterState_IsRunningMain() and friends last year, I tried to accommodate applications that embed Python but don't call _PyInterpreterState_SetRunningMain() (not that they're expected to). That mostly worked fine until my recent changes in gh-117049, where the subtleties with the fallback code led to failures; the change ended up breaking test_tools.test_freeze, which exercises a basic embedding situation. The simplest fix is to drop the fallback code I originally added to _PyInterpreterState_IsRunningMain() (and later to _PyThreadState_IsRunningMain()). I've kept the fallback in the _xxsubinterpreters module though. I've also updated Py_FrozenMain() to call _PyInterpreterState_SetRunningMain().
* gh-116522: Refactor `_PyThreadState_DeleteExcept` (#117131)Sam Gross2024-03-211-0/+8
| | | | | | | | | | | Split `_PyThreadState_DeleteExcept` into two functions: - `_PyThreadState_RemoveExcept` removes all thread states other than one passed as an argument. It returns the removed thread states as a linked list. - `_PyThreadState_DeleteList` deletes those dead thread states. It may call destructors, so we want to "start the world" before calling `_PyThreadState_DeleteList` to avoid potential deadlocks.
* gh-76785: Drop PyInterpreterID_Type (gh-117101)Eric Snow2024-03-215-25/+141
| | | I added it quite a while ago as a strategy for managing interpreter lifetimes relative to the PEP 554 (now 734) implementation. Relatively recently I refactored that implementation to no longer rely on InterpreterID objects. Thus now I'm removing it.
* gh-115754: Add Py_GetConstant() function (#116883)Victor Stinner2024-03-214-1/+85
| | | | | | | | | | | | Add Py_GetConstant() and Py_GetConstantBorrowed() functions. In the limited C API version 3.13, getting Py_None, Py_False, Py_True, Py_Ellipsis and Py_NotImplemented singletons is now implemented as function calls at the stable ABI level to hide implementation details. Getting these constants still return borrowed references. Add _testlimitedcapi/object.c and test_capi/test_object.py to test Py_GetConstant() and Py_GetConstantBorrowed() functions.
* gh-105716: Update interp->threads.main After Fork (gh-117049)Eric Snow2024-03-211-0/+4
| | | | | I missed this in gh-109921. We also update Py_Exit() to call _PyInterpreterState_SetNotRunningMain(), if necessary.
* gh-76785: Clean Up Interpreter ID Conversions (gh-117048)Eric Snow2024-03-213-108/+32
| | | Mostly we unify the two different implementations of the conversion code (from PyObject * to int64_t. We also drop the PyArg_ParseTuple()-style converter function, as well as rename and move PyInterpreterID_LookUp().
* gh-116522: Stop the world before fork() and during shutdown (#116607)Sam Gross2024-03-211-7/+21
| | | | | | | | | | | This changes the free-threaded build to perform a stop-the-world pause before deleting other thread states when forking and during shutdown. This fixes some crashes when using multiprocessing and during shutdown when running with `PYTHON_GIL=0`. This also changes `PyOS_BeforeFork` to acquire the runtime lock (i.e., `HEAD_LOCK(&_PyRuntime)`) before forking to ensure that data protected by the runtime lock (and not just the GIL or stop-the-world) is in a consistent state before forking.
* gh-114314: ctypes: remove stgdict and switch to heap types (GH-116458)Petr Viktorin2024-03-206-1404/+1402
| | | | | | | | | | | | | | | | | | | | | | | | | | | Before this change, ctypes classes used a custom dict subclass, `StgDict`, as their `tp_dict`. This acts like a regular dict but also includes extra information about the type. This replaces stgdict by `StgInfo`, a C struct on the type, accessed by `PyObject_GetTypeData()` (PEP-697). All usage of `StgDict` (mainly variables named `stgdict`, `dict`, `edict` etc.) is converted to `StgInfo` (named `stginfo`, `info`, `einfo`, etc.). Where the dict is actually used for class attributes (as a regular PyDict), it's now called `attrdict`. This change -- not overriding `tp_dict` -- is made to make me comfortable with the next part of this PR: moving the initialization logic from `tp_new` to `tp_init`. The `StgInfo` is set up in `__init__` of each class, with a guard that prevents calling `__init__` more than once. Note that abstract classes (like `Array` or `Structure`) are created using `PyType_FromMetaclass` and do not have `__init__` called. Previously, this was done in `__new__`, which also wasn't called for abstract classes. Since `__init__` can be called from Python code or skipped, there is a tested guard to ensure `StgInfo` is initialized exactly once before it's used. Co-authored-by: neonene <53406459+neonene@users.noreply.github.com> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* gh-116773: Ensure overlapped objects on Windows are not deallocated too ↵jkriegshauser2024-03-201-0/+18
| | | | early by asyncio (GH-116774)
* gh-117021: Fix integer overflow in PyLong_AsPid() on non-Windows 64-bit ↵Serhiy Storchaka2024-03-203-0/+25
| | | | platforms (GH-117064)
* gh-94808: add tests covering `PyFunction_{Get,Set}Closure` (GH-99429)Nikita Sobolev2024-03-201-0/+29
|
* GH-108362: Incremental Cycle GC (GH-116206)Mark Shannon2024-03-201-15/+10
|
* gh-113964: Don't prevent new threads until all non-daemon threads exit (#116677)Sam Gross2024-03-193-5/+7
| | | | | | | | | | Starting in Python 3.12, we prevented calling fork() and starting new threads during interpreter finalization (shutdown). This has led to a number of regressions and flaky tests. We should not prevent starting new threads (or `fork()`) until all non-daemon threads exit and finalization starts in earnest. This changes the checks to use `_PyInterpreterState_GetFinalizing(interp)`, which is set immediately before terminating non-daemon threads.
* gh-116417: Move limited C API complex.c tests to _testlimitedcapi (#117014)Victor Stinner2024-03-195-62/+84
| | | | Split complex.c tests of _testcapi into two parts: limited C API tests in _testlimitedcapi and non-limited C API tests in _testcapi.
* gh-116417: Move limited C API dict.c tests to _testlimitedcapi (#117006)Victor Stinner2024-03-195-279/+297
| | | | Split dict.c tests of _testcapi into two parts: limited C API tests in _testlimitedcapi and non-limited C API tests in _testcapi.
* gh-116417: Move limited C API long.c tests to _testlimitedcapi (#117001)Victor Stinner2024-03-198-895/+936
| | | | | | | * Split long.c tests of _testcapi into two parts: limited C API tests in _testlimitedcapi and non-limited C API tests in _testcapi. * Move testcapi_long.h from Modules/_testcapi/ to Modules/_testlimitedcapi/. * Add MODULE__TESTLIMITEDCAPI_DEPS to Makefile.pre.in.
* gh-116417: Move limited C API unicode.c tests to _testlimitedcapi (#116993)Victor Stinner2024-03-196-1883/+1961
| | | | | | Split unicode.c tests of _testcapi into two parts: limited C API tests in _testlimitedcapi and non-limited C API tests in _testcapi. Update test_codecs.
* gh-116417: Move limited C API abstract.c tests to _testlimitedcapi (#116986)Victor Stinner2024-03-197-647/+693
| | | | | | | Split abstract.c and float.c tests of _testcapi into two parts: limited C API tests in _testlimitedcapi and non-limited C API tests in _testcapi. Update test_bytes and test_class.
* gh-116417: Fix WASI build of _testlimitedcapi (#116974)Victor Stinner2024-03-1810-24/+26
| | | | Use different function names between _testcapi and _testlimitedcapi to not confuse the WASI linker.
* gh-116417: Move limited C API list.c tests to _testlimitedcapi (#116602)Victor Stinner2024-03-187-322/+368
| | | | | Split list.c and set.c tests of _testcapi into two parts: limited C API tests in _testlimitedcapi and non-limited C API tests in _testcapi.
* gh-115119: Switch Windows build to mpdecimal external (GH-115182)Zachary Ware2024-03-181-0/+17
| | | | | This includes adding what should be a relatively temporary `Modules/_decimal/windows/mpdecimal.h` shim to choose between `mpdecimal32vc.h` or `mpdecimal64vc.h` based on which of `CONFIG_64` or `CONFIG_32` is defined.
* gh-115874: Don't use module state in teedataobject tp_dealloc (#116204)Erlend E. Aasland2024-03-181-5/+3
| | | Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
* gh-115538: Emit warning when use bool as fd in _io.WindowsConsoleIO (GH-116925)AN Long2024-03-181-0/+7
|