summaryrefslogtreecommitdiffstats
path: root/Modules
Commit message (Collapse)AuthorAgeFilesLines
...
* gh-103092: Add a mutex to make the PRNG state of rotatingtree ↵AN Long2024-02-292-3/+10
| | | | concurrent-safe (#115301)
* gh-115398: Expose Expat >=2.6.0 reparse deferral API (CVE-2023-52425) ↵Sebastian Pipping2024-02-295-2/+155
| | | | | | | | | | | | | | | | | | | | | (GH-115623) Allow controlling Expat >=2.6.0 reparse deferral (CVE-2023-52425) by adding five new methods: - `xml.etree.ElementTree.XMLParser.flush` - `xml.etree.ElementTree.XMLPullParser.flush` - `xml.parsers.expat.xmlparser.GetReparseDeferralEnabled` - `xml.parsers.expat.xmlparser.SetReparseDeferralEnabled` - `xml.sax.expatreader.ExpatParser.flush` Based on the "flush" idea from https://github.com/python/cpython/pull/115138#issuecomment-1932444270 . ### Notes - Please treat as a security fix related to CVE-2023-52425. Includes code suggested-by: Snild Dolkow <snild@sony.com> and by core dev Serhiy Storchaka.
* gh-71052: Fix several Android build issues (#115955)Malcolm Smith2024-02-291-1/+1
| | | | | | | | | | | | | | | | | | | This change is part of the work on PEP-738: Adding Android as a supported platform. * Remove the "1.0" suffix from libpython's filename on Android, which would prevent Gradle from packaging it into an app. * Simplify the build command in the Makefile so that libpython always gets given an SONAME with the `-Wl-h` argument, even if the SONAME is identical to the actual filename. * Disable a number of functions on Android which can be compiled and linked against, but always fail at runtime. As a result, the native _multiprocessing module is no longer built for Android. * gh-115390 (bee7bb331) added some pre-determined results to the configure script for things that can't be autodetected when cross-compiling; this change adds Android to these where appropriate. * Add a couple more pre-determined results for Android, and making them cover iOS as well. This means the --enable-ipv6 configure option will no longer be required on either platform.
* gh-76785: Update test.support.interpreters to Align With PEP 734 (gh-115566)Eric Snow2024-02-282-36/+147
| | | | | This brings the code under test.support.interpreters, and the corresponding extension modules, in line with recent updates to PEP 734. (Note: PEP 734 has not been accepted at this time. However, we are using an internal copy of the implementation in the test suite to exercise the existing subinterpreters feature.)
* gh-112529: Simplify PyObject_GC_IsTracked and PyObject_GC_IsFinalized (#114732)Sam Gross2024-02-282-20/+49
|
* gh-115773: Add tests to exercise the _Py_DebugOffsets structure (#115774)Pablo Galindo Salgado2024-02-283-0/+631
|
* GH-115816: Assorted naming and formatting changes to improve ↵Mark Shannon2024-02-271-1/+1
| | | | | | | maintainability. (GH-115987) * Rename _Py_UOpsAbstractInterpContext to _Py_UOpsContext and _Py_UOpsSymType to _Py_UopsSymbol. * #define shortened form of _Py_uop_... names for improved readability.
* GH-115816: Make tier2 optimizer symbols testable, and add a few tests. ↵Mark Shannon2024-02-271-1/+2
| | | | (GH-115953)
* gh-115168: Add pystats counter for invalidated executors (GH-115169)Michael Droettboom2024-02-261-1/+1
|
* gh-115882: Reference Unknwn.h for ctypes on Windows (GH-115350)Yuriy Chernyshov2024-02-261-0/+4
| | | This allows the module to be compiled with WIN32_LEAN_AND_MEAN enabled
* gh-72249: Include the module name in the repr of partial object (GH-101910)Furkan Onder2024-02-251-2/+19
| | | Co-authored-by: Anilyka Barry <vgr255@live.ca>
* gh-115886: Handle embedded null characters in shared memory name (GH-115887)Serhiy Storchaka2024-02-251-2/+13
| | | | shm_open() and shm_unlink() now check for embedded null characters in the name and raise an error instead of silently truncating it.
* gh-67044: Always quote or escape \r and \n in csv.writer() (GH-115741)Serhiy Storchaka2024-02-231-0/+2
|
* gh-115714: Don't use CLOCK_PROCESS_CPUTIME_ID and times() on WASI (GH-115757)Petr Viktorin2024-02-221-5/+11
| | | | | * gh-115714: Don't use CLOCK_PROCESS_CPUTIME_ID and times() on WASI * Add blurb
* gh-111225: Link extension modules against libpython on Android (#115780)Malcolm Smith2024-02-211-13/+1
| | | | | | | | | | | | | | Part of the work on PEP 738: Adding Android as a supported platform. * Rename the LIBPYTHON variable to MODULE_LDFLAGS, to more accurately reflect its purpose. * Edit makesetup to use MODULE_LDFLAGS when linking extension modules. * Edit the Makefile so that extension modules depend on libpython on Android and Cygwin. * Restore `-fPIC` on Android. It was removed several years ago with a note that the toolchain used it automatically, but this is no longer the case. Omitting it causes all linker commands to fail with an error like `relocation R_AARCH64_ADR_PREL_PG_HI21 cannot be used against symbol '_Py_FalseStruct'; recompile with -fPIC`.
* gh-110850: Cleanup PyTime API: PyTime_t are nanoseconds (#115753)Victor Stinner2024-02-213-32/+27
| | | | | | | | | | PyTime_t no longer uses an arbitrary unit, it's always a number of nanoseconds (64-bit signed integer). * Rename _PyTime_FromNanosecondsObject() to _PyTime_FromLong(). * Rename _PyTime_AsNanosecondsObject() to _PyTime_AsLong(). * Remove pytime_from_nanoseconds(). * Remove pytime_as_nanoseconds(). * Remove _PyTime_FromNanoseconds().
* gh-110850: Replace private _PyTime_MAX with public PyTime_MAX (#115751)Victor Stinner2024-02-211-1/+1
| | | | | | | Remove references to the old names _PyTime_MIN and _PyTime_MAX, now that PyTime_MIN and PyTime_MAX are public. Replace also _PyTime_MIN with PyTime_MIN.
* gh-110850: Use public PyTime functions (#115746)Victor Stinner2024-02-209-52/+37
| | | | | Replace private _PyTime functions with public PyTime functions. random_seed_time_pid() now reports errors to its caller.
* gh-110850: Rename internal PyTime C API functions (#115734)Victor Stinner2024-02-206-19/+19
| | | | | | | | | | | | | | | | | Rename functions: * _PyTime_GetSystemClock() => _PyTime_TimeUnchecked() * _PyTime_GetPerfCounter() => _PyTime_PerfCounterUnchecked() * _PyTime_GetMonotonicClock() => _PyTime_MonotonicUnchecked() * _PyTime_GetSystemClockWithInfo() => _PyTime_TimeWithInfo() * _PyTime_GetMonotonicClockWithInfo() => _PyTime_MonotonicWithInfo() * _PyTime_GetMonotonicClockWithInfo() => _PyTime_MonotonicWithInfo() Changes: * Remove "typedef PyTime_t PyTime_t;" which was "typedef PyTime_t _PyTime_t;" before a previous rename. * Update comments of "Unchecked" functions. * Remove invalid PyTime_Time() comment.
* gh-104061: Add socket.SO_BINDTOIFINDEX constant (GH-104062)Victor Westerhuis2024-02-201-0/+3
| | | | | Add socket.SO_BINDTOIFINDEX constant This socket option avoids a race condition between SO_BINDTODEVICE and network interface renaming.
* Tier 2 cleanups and tweaks (#115534)Guido van Rossum2024-02-201-4/+4
| | | | | | | | | * Rename `_testinternalcapi.get_{uop,counter}_optimizer` to `new_*_optimizer` * Use `_PyUOpName()` instead of` _PyOpcode_uop_name[]` * Add `target` to executor iterator items -- `list(ex)` now returns `(opcode, oparg, target, operand)` quadruples * Add executor methods `get_opcode()` and `get_oparg()` to get `vmdata.opcode`, `vmdata.oparg` * Define a helper for printing uops, and unify various places where they are printed * Add a hack to summarize_stats.py to fix legacy uop names (e.g. `POP_TOP` -> `_POP_TOP`) * Define helpers in `test_opt.py` for accessing the set or list of opnames of an executor
* gh-110850: Cleanup pycore_time.h includes (#115724)Victor Stinner2024-02-2012-3/+13
| | | | | <pycore_time.h> include is no longer needed to get the PyTime_t type in internal header files. This type is now provided by <Python.h> include. Add <pycore_time.h> includes to C files instead.
* gh-115712: Support CSV dialects with delimiter=' ' and skipinitialspace=True ↵Serhiy Storchaka2024-02-201-7/+29
| | | | | | | | (GH-115721) Restore support of such combination, disabled in gh-113796. csv.writer() now quotes empty fields if delimiter is a space and skipinitialspace is true and raises exception if quoting is not possible.
* gh-110850: Replace _PyTime_t with PyTime_t (#115719)Victor Stinner2024-02-2015-112/+112
| | | | | Run command: sed -i -e 's!\<_PyTime_t\>!PyTime_t!g' $(find -name "*.c" -o -name "*.h")
* gh-112175: Add `eval_breaker` to `PyThreadState` (#115194)Brett Simmers2024-02-201-7/+4
| | | | | | | | | | | This change adds an `eval_breaker` field to `PyThreadState`. The primary motivation is for performance in free-threaded builds: with thread-local eval breakers, we can stop a specific thread (e.g., for an async exception) without interrupting other threads. The source of truth for the global instrumentation version is stored in the `instrumentation_version` field in PyInterpreterState. Threads usually read the version from their local `eval_breaker`, where it continues to be colocated with the eval breaker bits.
* gh-110850: Enhance PyTime C API tests (#115715)Victor Stinner2024-02-201-4/+9
|
* GH-112354: Initial implementation of warm up on exits and trace-stitching ↵Mark Shannon2024-02-201-1/+3
| | | | (GH-114142)
* gh-95782: Fix io.BufferedReader.tell() etc. being able to return offsets < 0 ↵6t8k2024-02-171-1/+10
| | | | | | | | | | | | | | | | | | | | (GH-99709) lseek() always returns 0 for character pseudo-devices like `/dev/urandom` (for other non-regular files, e.g. `/dev/stdin`, it always returns -1, to which CPython reacts by raising appropriate exceptions). They are thus technically seekable despite not having seek semantics. When calling read() on e.g. an instance of `io.BufferedReader` that wraps such a file, `BufferedReader` reads ahead, filling its buffer, creating a discrepancy between the number of bytes read and the internal `tell()` always returning 0, which previously resulted in e.g. `BufferedReader.tell()` or `BufferedReader.seek()` being able to return positions < 0 even though these are supposed to be always >= 0. Invariably keep the return value non-negative by returning max(former_return_value, 0) instead, and add some corresponding tests.
* gh-115103: Implement delayed memory reclamation (QSBR) (#115180)Sam Gross2024-02-161-0/+1
| | | | | | This adds a safe memory reclamation scheme based on FreeBSD's "GUS" and quiescent state based reclamation (QSBR). The API provides a mechanism for callers to detect when it is safe to free memory that may be concurrently accessed by readers.
* gh-114271: Make `thread._rlock` thread-safe in free-threaded builds (#115102)mpage2024-02-161-10/+22
| | | | | | | | | The ID of the owning thread (`rlock_owner`) may be accessed by multiple threads without holding the underlying lock; relaxed atomics are used in place of the previous loads/stores. The number of times that the lock has been acquired (`rlock_count`) is only ever accessed by the thread that holds the lock; we do not need to use atomics to access it.
* gh-112529: Make the GC scheduling thread-safe (#114880)Sam Gross2024-02-161-0/+10
| | | | | | | | | | The GC keeps track of the number of allocations (less deallocations) since the last GC. This buffers the count in thread-local state and uses atomic operations to modify the per-interpreter count. The thread-local buffering avoids contention on shared state. A consequence is that the GC scheduling is not as precise, so "test_sneaky_frame_object" is skipped because it requires that the GC be run exactly after allocating a frame object.
* gh-114572: Fix locking in cert_store_stats and get_ca_certs (#114573)David Benjamin2024-02-161-5/+60
| | | | | | | | | | | | | | | | | * gh-114572: Fix locking in cert_store_stats and get_ca_certs cert_store_stats and get_ca_certs query the SSLContext's X509_STORE with X509_STORE_get0_objects, but reading the result requires a lock. See https://github.com/openssl/openssl/pull/23224 for details. Instead, use X509_STORE_get1_objects, newly added in that PR. X509_STORE_get1_objects does not exist in current OpenSSLs, but we can polyfill it with X509_STORE_lock and X509_STORE_unlock. * Work around const-correctness problem * Add missing X509_STORE_get1_objects failure check * Add blurb
* gh-115498: Fix `SET_COUNT` error handling in `_xxinterpchannelsmodule` (#115499)Nikita Sobolev2024-02-151-1/+1
|
* gh-113743: Make the MRO cache thread-safe in free-threaded builds (#113930)Dino Viehland2024-02-151-11/+4
| | | | | | | Makes _PyType_Lookup thread safe, including: Thread safety of the underlying cache. Make mutation of mro and type members thread safe Also _PyType_GetMRO and _PyType_GetBases are currently returning borrowed references which aren't safe.
* gh-112433: Add optional _align_ attribute to ctypes.Structure (GH-113790)monkeyman1922024-02-151-1/+25
|
* gh-115432: Add critical section variant that handles a NULL object (#115433)Sam Gross2024-02-151-0/+9
| | | | | | This adds `Py_XBEGIN_CRITICAL_SECTION` and `Py_XEND_CRITICAL_SECTION`, which accept a possibly NULL object as an argument. If the argument is NULL, then nothing is locked or unlocked. Otherwise, they behave like `Py_BEGIN/END_CRITICAL_SECTION`.
* 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>