summaryrefslogtreecommitdiffstats
path: root/Modules
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* gh-116915: Make `_thread._ThreadHandle` support GC (#116934)mpage2024-03-181-3/+13
| | | | | | Even though it has no internal references to Python objects it still has a reference to its type by virtue of being a heap type. We need to provide a traverse function that visits the type, but we do not need to provide a clear function.
* gh-85283: Build _statistics extension with the limited C API (#116927)Victor Stinner2024-03-172-35/+17
| | | | | Argument Clinic now inlines _PyArg_CheckPositional() for the limited C API. The generated code should be as fast or even a little bit faster.
* gh-85283: Build termios extension with the limited C API (#116928)Victor Stinner2024-03-172-29/+38
|
* gh-73468: Add math.fma() function (#116667)Victor Stinner2024-03-172-1/+105
| | | | | | Added new math.fma() function, wrapping C99's ``fma()`` operation: fused multiply-add function. Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
* GH-112536: Add more TSan tests (#116911)Antoine Pitrou2024-03-171-2/+2
| | | | These may all exercise some non-trivial aspects of thread synchronization.
* gh-85287: Change codecs to raise precise UnicodeEncodeError and ↵John Sloboda2024-03-171-5/+37
| | | | | UnicodeDecodeError (#113674) Co-authored-by: Inada Naoki <songofacandy@gmail.com>
* gh-114271: Fix race in `Thread.join()` (#114839)mpage2024-03-161-305/+674
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is a race between when `Thread._tstate_lock` is released[^1] in `Thread._wait_for_tstate_lock()` and when `Thread._stop()` asserts[^2] that it is unlocked. Consider the following execution involving threads A, B, and C: 1. A starts. 2. B joins A, blocking on its `_tstate_lock`. 3. C joins A, blocking on its `_tstate_lock`. 4. A finishes and releases its `_tstate_lock`. 5. B acquires A's `_tstate_lock` in `_wait_for_tstate_lock()`, releases it, but is swapped out before calling `_stop()`. 6. C is scheduled, acquires A's `_tstate_lock` in `_wait_for_tstate_lock()` but is swapped out before releasing it. 7. B is scheduled, calls `_stop()`, which asserts that A's `_tstate_lock` is not held. However, C holds it, so the assertion fails. The race can be reproduced[^3] by inserting sleeps at the appropriate points in the threading code. To do so, run the `repro_join_race.py` from the linked repo. There are two main parts to this PR: 1. `_tstate_lock` is replaced with an event that is attached to `PyThreadState`. The event is set by the runtime prior to the thread being cleared (in the same place that `_tstate_lock` was released). `Thread.join()` blocks waiting for the event to be set. 2. `_PyInterpreterState_WaitForThreads()` provides the ability to wait for all non-daemon threads to exit. To do so, an `is_daemon` predicate was added to `PyThreadState`. This field is set each time a thread is created. `threading._shutdown()` now calls into `_PyInterpreterState_WaitForThreads()` instead of waiting on `_tstate_lock`s. [^1]: https://github.com/python/cpython/blob/441affc9e7f419ef0b68f734505fa2f79fe653c7/Lib/threading.py#L1201 [^2]: https://github.com/python/cpython/blob/441affc9e7f419ef0b68f734505fa2f79fe653c7/Lib/threading.py#L1115 [^3]: https://github.com/mpage/cpython/commit/81946532792f938cd6f6ab4c4ff92a4edf61314f --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Antoine Pitrou <antoine@python.org>
* gh-85283: Build pwd extension with the limited C API (#116841)Victor Stinner2024-03-152-5/+10
| | | | Argument Clinic now uses the PEP 737 "%T" format to format type name for the limited C API.
* gh-116195: Implements a fast path for nt.getppid (GH-116205)vxiiduu2024-03-141-2/+84
| | | | | Use the NtQueryInformationProcess system call to efficiently retrieve the parent process ID in a single step, rather than using the process snapshots API which retrieves large amounts of unnecessary information and is more prone to failure (since it makes heap allocations). Includes a fallback to the original win32_getppid implementation in case the unstable API appears to return strange results.
* gh-111696, PEP 737: Add PyType_GetModuleName() function (#116824)Victor Stinner2024-03-143-10/+10
| | | Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
* gh-111696, PEP 737: Add PyType_GetFullyQualifiedName() function (#116815)Victor Stinner2024-03-141-68/+17
| | | Rewrite tests on type names in Python, they were written in C.
* gh-116646, AC: Always use PyObject_AsFileDescriptor() in fildes (#116806)Victor Stinner2024-03-143-38/+67
| | | | | | | The fildes converter of Argument Clinic now always call PyObject_AsFileDescriptor(), not only for the limited C API. The _PyLong_FileDescriptor_Converter() converter stays as a fallback when PyObject_AsFileDescriptor() cannot be used.
* gh-116646, AC: Add CConverter.use_converter() method (#116793)Victor Stinner2024-03-141-2/+1
| | | Only add includes when the converter is effectively used.
* gh-85283: Build fcntl extension with the limited C API (#116791)Victor Stinner2024-03-142-24/+44
|
* gh-116646: Add limited C API support to AC fildes converter (#116769)Victor Stinner2024-03-142-1/+52
| | | Add tests on the "fildes" converter to _testclinic_limited.
* gh-116616: Use relaxed atomic ops to access socket module defaulttimeout ↵Erlend E. Aasland2024-03-121-5/+6
| | | | | (#116623) Co-authored-by: Sam Gross <colesbury@gmail.com>
* gh-116541: Handle errors correctly in `_pystatvfs_fromstructstatvfs` (#116542)Nikita Sobolev2024-03-121-32/+36
|
* gh-85283: Convert grp extension to the limited C API (#116611)Victor Stinner2024-03-123-82/+18
| | | | posixmodule.h: remove check on the limited C API, since these helpers are not part of the public C API.
* gh-108494: Fix Argument Clinic LIMITED_CAPI_REGEX (#116610)Victor Stinner2024-03-1111-31/+21
| | | Accept spaces in "# define Py_LIMITED_API 0x030d0000".
* gh-110850: Fix _PyTime_FromSecondsDouble() API (#116606)Victor Stinner2024-03-112-22/+32
| | | | | | | | Return 0 on success. Set an exception and return -1 on error. Fix os.timerfd_settime(): properly report exceptions on _PyTime_FromSecondsDouble() failure. No longer export _PyTime_FromSecondsDouble().
* gh-116417: Build _testinternalcapi with limited C API version 3.5 (#116598)Victor Stinner2024-03-113-2/+15
|
* gh-116545: Fix error handling in `mkpwent` in `pwdmodule` (#116548)Nikita Sobolev2024-03-111-31/+30
|
* gh-116417: Move 4 limited C API test files to _testlimitedcapi (#116571)Victor Stinner2024-03-1110-24/+57
| | | | | | | | | | | | | | | | Move the following files from Modules/_testcapi/ to Modules/_testlimitedcapi/: * bytearray.c * bytes.c * pyos.c * sys.c Changes: * Replace PyBytes_AS_STRING() with PyBytes_AsString(). * Replace PyBytes_GET_SIZE() with PyBytes_Size(). * Update related test_capi tests. * Copy Modules/_testcapi/util.h to Modules/_testlimitedcapi/util.h.
* gh-116417: Fix make check-c-globals for _testlimitedcapi (#116570)Victor Stinner2024-03-101-4/+0
| | | | | * Remove unused '_testcapimodule' global in Modules/_testcapi/unicode.c. * Update c-analyzer to not use the internal C API in _testlimitedcapi.c.
* gh-116417: Avoid PyFloat_AS_DOUBLE() in AC limited C API (#116568)Victor Stinner2024-03-102-1/+119
| | | | Argument Clinic no longer calls PyFloat_AS_DOUBLE() when the usage of the limited C API is requested.
* gh-116520: Fix error handling in `os_get_terminal_size_impl` in ↵Nikita Sobolev2024-03-091-6/+17
| | | | `posixmodule` (#116521)
* gh-116447: Fix possible UB in `arraymodule` and `getargs` (#116459)Nikita Sobolev2024-03-081-1/+1
|
* gh-116303: Explicitly check for the _testsinglephase module in configure.ac ↵Erlend E. Aasland2024-03-071-1/+1
| | | | (#116479)
* gh-116417: Add _testlimitedcapi C extension (#116419)Victor Stinner2024-03-079-53/+96
| | | | | | | | | | | | | Add a new C extension "_testlimitedcapi" which is only built with the limited C API. Move heaptype_relative.c and vectorcall_limited.c from Modules/_testcapi/ to Modules/_testlimitedcapi/. * configure: add _testlimitedcapi test extension. * Update generate_stdlib_module_names.py. * Update make check-c-globals. Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* gh-116437: Use new C API PyDict_Pop() to simplify the code (GH-116438)Serhiy Storchaka2024-03-076-53/+45
|
* gh-116448: Handle errors correctly in `os_waitid_impl` in `posixmodule` ↵Nikita Sobolev2024-03-071-9/+19
| | | | (#116449)
* gh-116386: Fix format string "%ld" warning in `_xxinterpqueuesmodule` (#116387)Nikita Sobolev2024-03-071-1/+1
|
* gh-114099 - Add iOS testbed, plus Makefile target to invoke it. (gh-115930)Russell Keith-Magee2024-03-071-4/+7
|
* gh-114271: Make `_thread.lock` thread-safe in free-threaded builds (#116433)mpage2024-03-061-2/+2
| | | | | | | | Previously, the `locked` field was set after releasing the lock. This reverses the order so that the `locked` field is set while the lock is still held. There is still one thread-safety issue where `locked` is checked prior to releasing the lock, however, in practice that will only be an issue when unlocking the lock is contended, which should be rare.
* gh-116404: Handle errors correctly in `wait_helper` in `posixmodule` (#116405)Nikita Sobolev2024-03-061-26/+29
|
* gh-76785: Use PRId64 to Fix a Compiler Warning on Windows (gh-116369)Eric Snow2024-03-051-2/+2
| | | I accidentally introduced the warning in gh-116328.
* gh-76785: Minor Improvements to "interpreters" Module (gh-116328)Eric Snow2024-03-053-68/+215
| | | This includes adding pickle support to various classes, and small changes to improve the maintainability of the low-level _xxinterpqueues module.
* gh-115490: Make the interpreter.channels and interpreter.queues Modules ↵Eric Snow2024-03-042-12/+19
| | | | | Handle Reloading Properly (gh-115493) The problem manifested when the .py module got reloaded and the corresponding extension module didn't. The .py module registers types with the extension and the extension was not allowing that to happen more than once. The solution: let it happen more than once.
* gh-76785: Simplify Channels XID Types (gh-116318)Eric Snow2024-03-041-78/+49
| | | I had added an extra cleanup abstraction a while back that has turned out to be unnecessary.
* gh-116116: Backport blake2 change to fix building with clang-cl on ↵Yuriy Chernyshov2024-03-042-2/+2
| | | | windows-i686 (GH-116117)
* Consistently spell out *predicate* instead of *pred*. (gh-116308)Raymond Hettinger2024-03-041-3/+3
|
* gh-108562: Fix compiler warnings for libmpdec (#114751)Sergey B Kirpichev2024-03-031-0/+1
| | | | | | If awailable, enable -fstrict-overflow for libmpdec. Also shut off false positive warnings (-Warray-bounds). The later was backported from mpdecimal-4.0.0.
* gh-116102: Silence a Compiler Warning in _xxinterpqueues (gh-116230)Eric Snow2024-03-021-1/+1
|
* gh-114271: Make `_thread.ThreadHandle` thread-safe in free-threaded builds ↵mpage2024-03-011-40/+127
| | | | | | | | | | | | | | | | | (GH-115190) Make `_thread.ThreadHandle` thread-safe in free-threaded builds We protect the mutable state of `ThreadHandle` using a `_PyOnceFlag`. Concurrent operations (i.e. `join` or `detach`) on `ThreadHandle` block until it is their turn to execute or an earlier operation succeeds. Once an operation has been applied successfully all future operations complete immediately. The `join()` method is now idempotent. It may be called multiple times but the underlying OS thread will only be joined once. After `join()` succeeds, any future calls to `join()` will succeed immediately. The internal thread handle `detach()` method has been removed.
* gh-115773: Add missing preprocessor guard in _testexternalinspection (#116212)Malcolm Smith2024-03-011-1/+1
| | | Add missing preprocessor guard in _testexternalinspection
* gh-116099: Fix refcounting bug in `_queueobj_shared()` (gh-116164)Brett Simmers2024-03-011-3/+1
| | | | | | | | | This code decrefs `qidobj` twice in some paths. Since `qidobj` isn't used after the first `Py_DECREF()`, remove the others, and replace the `Py_DECREF()` with `Py_CLEAR()` to make it clear that the variable is dead. With this fix, `python -mtest test_interpreters -R 3:3 -mtest_queues` no longer fails with `_Py_NegativeRefcount: Assertion failed: object has negative ref count`.