summaryrefslogtreecommitdiffstats
path: root/Modules
Commit message (Collapse)AuthorAgeFilesLines
* gh-112050: Make collections.deque thread-safe in free-threaded builds (#113830)mpage2024-02-152-61/+335
| | | | | | | Use critical sections to make deque methods that operate on mutable state thread-safe when the GIL is disabled. This is mostly accomplished by using the @critical_section Argument Clinic directive, though there are a few places where this was not possible and critical sections had to be manually acquired/released.
* gh-114570: Add PythonFinalizationError exception (#115352)Victor Stinner2024-02-144-6/+6
| | | | | | | | | | | | | | | | | Add PythonFinalizationError exception. This exception derived from RuntimeError is raised when an operation is blocked during the Python finalization. The following functions now raise PythonFinalizationError, instead of RuntimeError: * _thread.start_new_thread() * subprocess.Popen * os.fork() * os.fork1() * os.forkpty() Morever, _winapi.Overlapped finalizer now logs an unraisable PythonFinalizationError, instead of an unraisable RuntimeError.
* gh-115399: Upgrade bundled libexpat to 2.6.0 (#115431)Seth Michael Larson2024-02-1411-262/+401
|
* gh-115243: Fix crash in deque.index() when the deque is concurrently ↵kcatss2024-02-141-1/+2
| | | | modified (GH-115247)
* gh-76785: Improved Subinterpreters Compatibility with 3.12 (gh-115424)Eric Snow2024-02-134-50/+74
| | | | | For the most part, these changes make is substantially easier to backport subinterpreter-related code to 3.12, especially the related modules (e.g. _xxsubinterpreters). The main motivation is to support releasing a PyPI package with the 3.13 capabilities compiled for 3.12. A lot of the changes here involve either hiding details behind macros/functions or splitting up some files.
* gh-115417: Remove accidentally left debugging print (#115418)Kirill Podoprigora2024-02-131-1/+0
| | | gh-115417: Remove debugging print
* gh-89240: Enable multiprocessing on Windows to use large process pools ↵Steve Dower2024-02-132-1/+1003
| | | | | | | (GH-107873) We add _winapi.BatchedWaitForMultipleObjects to wait for larger numbers of handles. This is an internal module, hence undocumented, and should be used with caution. Check the docstring for info before using BatchedWaitForMultipleObjects.
* gh-111140: Adds PyLong_AsNativeBytes and PyLong_FromNative[Unsigned]Bytes ↵Steve Dower2024-02-128-16/+71
| | | | functions (GH-114886)
* gh-114271: Make `PyInterpreterState.threads.count` thread-safe in ↵mpage2024-02-121-3/+3
| | | | | free-threaded builds (gh-115093) Use atomics to mutate PyInterpreterState.threads.count.
* gh-110850: Add PyTime_t C API (GH-115215)Petr Viktorin2024-02-126-18/+111
| | | | | | | | | | | | * gh-110850: Add PyTime_t C API Add PyTime_t API: * PyTime_t type. * PyTime_MIN and PyTime_MAX constants. * PyTime_AsSecondsDouble(), PyTime_Monotonic(), PyTime_PerfCounter() and PyTime_GetSystemClock() functions. Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-87804: Fix the refleak in error handling of `_pystatvfs_fromstructstatfs` ↵Nikita Sobolev2024-02-121-8/+9
| | | | | (#115335) It was the macro expansion! Sorry!
* gh-115058: Add ``reset_rare_event_counters`` function in `_testinternalcapi` ↵Kirill Podoprigora2024-02-121-0/+15
| | | | (GH-115128)
* gh-89039: Call subclass constructors in datetime.*.replace (GH-114780)Eugene Toder2024-02-121-15/+62
| | | | | | | | | When replace() method is called on a subclass of datetime, date or time, properly call derived constructor. Previously, only the base class's constructor was called. Also, make sure to pass non-zero fold values when creating subclasses in various methods. Previously, fold was silently ignored.
* gh-114563: C decimal falls back to pydecimal for unsupported format strings ↵John Belmonte2024-02-121-122/+62
| | | | | | | | | | | | | | | | | | (GH-114879) Immediate merits: * eliminate complex workarounds for 'z' format support (NOTE: mpdecimal recently added 'z' support, so this becomes efficient in the long term.) * fix 'z' format memory leak * fix 'z' format applied to 'F' * fix missing '#' format support Suggested and prototyped by Stefan Krah. Fixes gh-114563, gh-91060 Co-authored-by: Stefan Krah <skrah@bytereef.org>
* gh-87804: Fix error handling and style in `_pystatvfs_fromstructstatfs` ↵Nikita Sobolev2024-02-121-31/+33
| | | | (#115236)
* gh-49766: Make date-datetime comparison more symmetric and flexible (GH-114760)Serhiy Storchaka2024-02-111-26/+10
| | | | | | | | | | | | | Now the special comparison methods like `__eq__` and `__lt__` return NotImplemented if one of comparands is date and other is datetime instead of ignoring the time part and the time zone or forcefully return "not equal" or raise TypeError. It makes comparison of date and datetime subclasses more symmetric and allows to change the default behavior by overriding the special comparison methods in subclasses. It is now the same as if date and datetime was independent classes.
* gh-85984: Add _POSIX_VDISABLE from unistd.h to termios module. (#114985)Soumendra Ganguly2024-02-111-3/+4
| | | | Signed-off-by: Soumendra Ganguly <soumendraganguly@gmail.com> Co-authored-by: Gregory P. Smith <greg@krypto.org>
* gh-114670: Fix `_testbuffer` module initialization (#114672)Nikita Sobolev2024-02-101-53/+74
|
* gh-114894: add array.array.clear() method (#114919)Mike Zimin2024-02-102-1/+35
| | | | | Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: AN Long <aisk@users.noreply.github.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* GH-87804: Fix counter overflow in statvfs on macOS (#99570)Ronald Oussoren2024-02-101-0/+101
| | | | | | | | | | On macOS the statvfs interface returns block counts as 32-bit integers, and that results in bad reporting for larger disks. Therefore reimplement statvfs in terms of statfs, which does use 64-bit integers for block counts. Tested using a sparse filesystem image of 100TB.
* gh-110481: Implement inter-thread queue for biased reference counting (#114824)Sam Gross2024-02-091-0/+4
| | | | | | | | | Biased reference counting maintains two refcount fields in each object: `ob_ref_local` and `ob_ref_shared`. The true refcount is the sum of these two fields. In some cases, when refcounting operations are split across threads, the ob_ref_shared field can be negative (although the total refcount must be at least zero). In this case, the thread that decremented the refcount requests that the owning thread give up ownership and merge the refcount fields.
* gh-115059: Flush the underlying write buffer in io.BufferedRandom.read1() ↵Serhiy Storchaka2024-02-091-0/+10
| | | | (GH-115163)
* gh-115136: Fix possible NULL deref in getpath_joinpath() (GH-115137)Artem Chernyshev2024-02-081-0/+4
| | | | Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
* When the Py_CompileStringExFlags fuzzer encounters a SystemError, abort ↵Alex Gaynor2024-02-071-2/+9
| | | | | (#115147) This allows us to catch bugs beyond memory corruption and assertions.
* gh-112066: Use `PyDict_SetDefaultRef` in place of `PyDict_SetDefault`. (#112211)Sam Gross2024-02-073-5/+5
| | | | | This changes a number of internal usages of `PyDict_SetDefault` to use `PyDict_SetDefaultRef`. Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* GH-108362: Revert "GH-108362: Incremental GC implementation (GH-108038)" ↵Mark Shannon2024-02-071-9/+14
| | | | | | | (#115132) Revert "GH-108362: Incremental GC implementation (GH-108038)" This reverts commit 36518e69d74607e5f094ce55286188e4545a947d.
* gh-112075: Add critical sections for most dict APIs (#114508)Dino Viehland2024-02-061-12/+15
| | | | | | | | | Starts adding thread safety to dict objects. Use @critical_section for APIs which are exposed via argument clinic and don't directly correlate with a public C API which needs to acquire the lock Use a _lock_held suffix for keeping changes to complicated functions simple and just wrapping them with a critical section Acquire and release the lock in an existing function where it won't be overly disruptive to the existing logic
* gh-115035: Mark ThreadHandles as non-joinable earlier after forking (#115042)Sam Gross2024-02-061-17/+36
| | | | | | This marks dead ThreadHandles as non-joinable earlier in `PyOS_AfterFork_Child()` before we execute any Python code. The handles are stored in a global linked list in `_PyRuntimeState` because `fork()` affects the entire process.
* gh-112529: Stop the world around gc.get_referents (#114823)Sam Gross2024-02-061-13/+28
| | | | | | | We do not want to add locking in `tp_traverse` slot implementations. Instead, stop the world when calling `gc.get_referents`. Note that the the stop the world call is a no-op in the default build. Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* gh-112066: Add `PyDict_SetDefaultRef` function. (#112123)Sam Gross2024-02-061-0/+26
| | | | | | | The `PyDict_SetDefaultRef` function is similar to `PyDict_SetDefault`, but returns a strong reference through the optional `**result` pointer instead of a borrowed reference. Co-authored-by: Petr Viktorin <encukou@gmail.com>
* gh-91602: Add iterdump() support for filtering database objects (#114501)Mariusz Felisiak2024-02-062-11/+69
| | | | | | Add optional 'filter' parameter to iterdump() that allows a "LIKE" pattern for filtering database objects to dump. Co-authored-by: Erlend E. Aasland <erlend@python.org>
* gh-82626: Emit a warning when bool is used as a file descriptor (GH-111275)Serhiy Storchaka2024-02-053-0/+21
|
* gh-115015: Argument Clinic: fix generated code for METH_METHOD methods ↵Erlend E. Aasland2024-02-0525-65/+124
| | | | without params (#115016)
* GH-108362: Incremental GC implementation (GH-108038)Mark Shannon2024-02-051-14/+9
|
* gh-115026: Argument Clinic: handle PyBuffer_FillInfo errors in generated ↵Nikita Sobolev2024-02-053-9/+21
| | | | code (#115027)
* gh-114685: PyBuffer_FillInfo() now raises on PyBUF_{READ,WRITE} (GH-114802)Nikita Sobolev2024-02-041-0/+21
|
* gh-111417: Remove unused code block in math.trunc() and round() (GH-111454)Jason Zhang2024-02-031-5/+0
| | | _PyObject_LookupSpecial() now ensures that the type is ready.
* gh-114329: Add `PyList_GetItemRef` function (GH-114504)Sam Gross2024-02-021-0/+13
| | | | | | | The new `PyList_GetItemRef` is similar to `PyList_GetItem`, but returns a strong reference instead of a borrowed reference. Additionally, if the passed "list" object is not a list, the function sets a `TypeError` instead of calling `PyErr_BadInternalCall()`.
* GH-113710: Add a "globals to constants" pass (GH-114592)Mark Shannon2024-02-021-2/+2
| | | Converts specializations of `LOAD_GLOBAL` into constants during tier 2 optimization.
* gh-112529: Remove PyGC_Head from object pre-header in free-threaded build ↵Sam Gross2024-02-011-1/+11
| | | | | | | | | | | | | | | | | (#114564) * gh-112529: Remove PyGC_Head from object pre-header in free-threaded build This avoids allocating space for PyGC_Head in the free-threaded build. The GC implementation for free-threaded CPython does not use the PyGC_Head structure. * The trashcan mechanism uses the `ob_tid` field instead of `_gc_prev` in the free-threaded build. * The GDB libpython.py file now determines the offset of the managed dict field based on whether the running process is a free-threaded build. Those are identified by the `ob_ref_local` field in PyObject. * Fixes `_PySys_GetSizeOf()` which incorrectly incorrectly included the size of `PyGC_Head` in the size of static `PyTypeObject`.
* gh-114685: Check flags in PyObject_GetBuffer() (GH-114707)Serhiy Storchaka2024-01-311-2/+4
| | | | | PyObject_GetBuffer() now raises a SystemError if called with PyBUF_READ or PyBUF_WRITE as flags. These flags should only be used with the PyMemoryView_* C API.
* gh-110190: Fix ctypes structs with array on Windows ARM64 (GH-114753)Diego Russo2024-01-301-1/+1
|
* gh-112919: Speed-up datetime, date and time.replace() (GH-112921)Eugene Toder2024-01-302-96/+426
| | | | | Use argument clinic and call new_* functions directly. This speeds up these functions 6x to 7.5x when calling with keyword arguments.
* gh-113732: Fix support of QUOTE_NOTNULL and QUOTE_STRINGS in csv.reader ↵Serhiy Storchaka2024-01-301-17/+29
| | | | (GH-113738)
* gh-114678: Fix incorrect deprecation warning for 'N' specifier in Decimal ↵Serhiy Storchaka2024-01-291-6/+8
| | | | | format (GH-114683) Co-authored-by: Stefan Krah <skrah@bytereef.org>
* gh-85984: Add POSIX pseudo-terminal functions. (GH-102413)Soumendra Ganguly2024-01-292-1/+314
| | | | | Signed-off-by: Soumendra Ganguly <soumendraganguly@gmail.com> Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Petr Viktorin <encukou@gmail.com>
* gh-91325: Skip Stable ABI checks with Py_TRACE_REFS special build (GH-92046)Petr Viktorin2024-01-291-0/+9
| | | | | | Skip Stable ABI checks with Py_TRACE_REFS special build This build is not compatible with Py_LIMITED_API nor with the stable ABI.
* gh-112050: Adapt collections.deque to Argument Clinic (#113963)mpage2024-01-292-152/+678
|
* Use Unicode unconditionally for _winapi.CreateFile (GH-114611)Steve Dower2024-01-262-13/+17
| | | Currently it switches based on build settings, but argument clinic does not handle it correctly.
* gh-114569: Use PyMem_* APIs for most non-PyObject uses (#114574)Erlend E. Aasland2024-01-264-19/+22
| | | Fix usage in Modules, Objects, and Parser subdirectories.