summaryrefslogtreecommitdiffstats
path: root/Modules
Commit message (Collapse)AuthorAgeFilesLines
* gh-110260: Check for PyList_SetItem() errors in termios module (GH-110261)Nikita Sobolev2023-10-041-17/+32
|
* gh-110300: Fix Refleaks in test_interpreters and test__xxinterpchannels ↵Eric Snow2023-10-041-2/+9
| | | | (gh-110318)
* Revert "gh-76785: Print the Traceback from Interpreter.run() (gh-110248)" ↵Eric Snow2023-10-031-4/+0
| | | | | | | (gh-110314) This reverts commit 6bc889aedc11cc8e0b9f57948a3d528ad2685497. That commit is causing some buildbot failures.
* gh-76785: Print the Traceback from Interpreter.run() (gh-110248)Eric Snow2023-10-031-0/+4
| | | This is a temporary fix. The full fix may involve serializing the traceback in some form.
* gh-108867: Add PyThreadState_GetUnchecked() function (#108870)Victor Stinner2023-10-032-3/+4
| | | | | | Add PyThreadState_GetUnchecked() function: similar to PyThreadState_Get(), but don't issue a fatal error if it is NULL. The caller is responsible to check if the result is NULL. Previously, this function was private and known as _PyThreadState_UncheckedGet().
* gh-109860: Use a New Thread State When Switching Interpreters, When ↵Eric Snow2023-10-032-45/+68
| | | | | | | | | Necessary (gh-110245) In a few places we switch to another interpreter without knowing if it has a thread state associated with the current thread. For the main interpreter there wasn't much of a problem, but for subinterpreters we were *mostly* okay re-using the tstate created with the interpreter (located via PyInterpreterState_ThreadHead()). There was a good chance that tstate wasn't actually in use by another thread. However, there are no guarantees of that. Furthermore, re-using an already used tstate is currently fragile. To address this, now we create a new thread state in each of those places and use it. One consequence of this change is that PyInterpreterState_ThreadHead() may not return NULL (though that won't happen for the main interpreter).
* gh-110241: Add missing error check to `record_eval` in `_testinternalcapi` ↵Nikita Sobolev2023-10-021-1/+5
| | | | (#110242)
* gh-76785: Module-level Fixes for test.support.interpreters (gh-110236)Eric Snow2023-10-021-20/+165
| | | | | * add RecvChannel.close() and SendChannel.close() * make RecvChannel and SendChannel shareable * expose ChannelEmptyError and ChannelNotEmptyError
* gh-105716: Support Background Threads in Subinterpreters Consistently ↵Eric Snow2023-10-023-44/+60
| | | | | | | (gh-109921) The existence of background threads running on a subinterpreter was preventing interpreters from getting properly destroyed, as well as impacting the ability to run the interpreter again. It also affected how we wait for non-daemon threads to finish. We add PyInterpreterState.threads.main, with some internal C-API functions.
* gh-109853: Fix sys.path[0] For Subinterpreters (gh-109994)Eric Snow2023-10-021-10/+28
| | | This change makes sure sys.path[0] is set properly for subinterpreters. Before, it wasn't getting set at all. This PR does not address the broader concerns from gh-109853.
* gh-107073: Make PyObject_VisitManagedDict() public (#108763)Victor Stinner2023-10-023-7/+7
| | | | | | | | Make PyObject_VisitManagedDict() and PyObject_ClearManagedDict() functions public in Python 3.13 C API. * Rename _PyObject_VisitManagedDict() to PyObject_VisitManagedDict(). * Rename _PyObject_ClearManagedDict() to PyObject_ClearManagedDict(). * Document these functions.
* gh-109649: Use os.process_cpu_count() (#110165)Victor Stinner2023-10-011-1/+1
| | | | | | | | | | | | | | | | | | | | Replace os.cpu_count() with os.process_cpu_count() in modules: * compileall * concurrent.futures * multiprocessing Replace os.cpu_count() with os.process_cpu_count() in programs: * _decimal deccheck.py test * freeze.py * multissltests.py * python -m test (regrtest) * wasm_build.py Other changes: * test.pythoninfo logs os.process_cpu_count(). * regrtest gets os.process_cpu_count() / os.cpu_count() in headers.
* gh-109649: Add os.process_cpu_count() function (#109907)Victor Stinner2023-09-302-36/+45
| | | | | | | | | * Refactor os_sched_getaffinity_impl(): move variable definitions to their first assignment. * Fix test_posix.test_sched_getaffinity(): restore the old CPU mask when the test completes! * Doc: Specify that os.cpu_count() counts *logicial* CPUs. * Doc: Specify that os.sched_getaffinity(0) is related to the calling thread.
* gh-110014: Include explicitly <unistd.h> header (#110155)Victor Stinner2023-09-304-25/+34
| | | | | | | | | | | * Remove unused <locale.h> includes. * Remove unused <fcntl.h> include in traceback.h. * Remove redundant <assert.h> and <stddef.h> includes. They are already included by "Python.h". * Remove <object.h> include in faulthandler.c. Python.h already includes it. * Add missing <stdbool.h> in pycore_pythread.h if HAVE_PTHREAD_STUBS is defined. * Fix also warnings in pthread_stubs.h: don't redefine macros if they are already defined, like the __NEED_pthread_t macro.
* gh-105323: Update readline module to detect apple editline variant (gh-108665)Donghee Na2023-09-291-0/+4
|
* gh-110079: Remove extern "C" { ...} in C code (#110080)Victor Stinner2023-09-294-32/+0
|
* gh-110045: Update symtable module for PEP 695 (#110066)Jelle Zijlstra2023-09-291-0/+8
|
* gh-110052: Fix faulthandler for freed tstate (#110069)Victor Stinner2023-09-291-2/+1
| | | | faulthandler now detected freed interp and freed tstate, and no longer dereference them.
* gh-109782: Ensure `os.path.isdir` has the same signature on all platforms ↵Amin Alaee2023-09-282-13/+13
| | | | (GH-109790)
* gh-109098: Fuzz re module instead of internal sre (#109911)Ammar Askar2023-09-261-27/+18
| | | | | * gh-109098: Fuzz re module instead of internal sre * Fix c-analyzer globals test failure * Put globals exception in ignored.tsv
* gh-109593: Fix reentrancy issue in multiprocessing resource_tracker (#109629)Antoine Pitrou2023-09-261-0/+14
| | | | | --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* gh-109631: Allow interruption of short repeated regex matches (GH-109867)Serhiy Storchaka2023-09-262-2/+5
| | | | Counting for signal checking now continues in new match from the point where it ended in the previous match instead of starting from 0.
* gh-109795: `_thread.start_new_thread`: allocate thread bootstate using raw ↵Radislav Chugunov2023-09-251-3/+6
| | | | memory allocator (#109808)
* gh-109723: Fix build of _testclinic_limited on WASM (#109842)Victor Stinner2023-09-251-0/+6
| | | Make sure that the Py_BUILD_CORE macro is not defined.
* gh-104469: Convert _testcapi/vectorcall_limited.c to use AC (#109691)Victor Stinner2023-09-252-5/+47
| | | Co-authored-by: nahyeon <55136494+nahyeon-an@users.noreply.github.com>
* gh-109611: Add convenient C API function _PyFile_Flush() (GH-109612)Serhiy Storchaka2023-09-235-55/+27
|
* gh-109723: Disable Py_BUILD_CORE in _testcapi (#109727)Victor Stinner2023-09-227-95/+103
| | | | | | | | | | | | | | | | | | Make sure that the internal C API is not tested by mistake by _testcapi. Undefine Py_BUILD_CORE_BUILTIN and Py_BUILD_CORE_MODULE macros in Modules/_testcapi/parts.h: move code from _testcapimodule.c. heaptype_relative.c and vectorcall_limited.c are using the limited C API which is incompatible with the internal C API. Move test_long_numbits() from _testcapi to _testinternalcapi since it uses the internal C API "pycore_long.h". Fix Modules/_testcapi/pyatomic.c: don't include Python.h directly, just include _testcapi/parts.h. Ajust "make check-c-globals" for these changes.
* gh-109693: Remove pycore_atomic_funcs.h (#109694)Sam Gross2023-09-211-13/+0
| | | _PyUnicode_FromId() now uses pyatomic.h functions instead.
* gh-109613: _pystat_fromstructstat() checks for exceptions (#109618)Victor Stinner2023-09-211-49/+72
| | | | | | | | | | | | | Fix os.stat() and os.DirEntry.stat(): check for exceptions. Previously, on Python built in debug mode, these functions could trigger a fatal Python error (and abort the process) when a function succeeded with an exception set. _pystat_fromstructstat() now exits immediately if an exception is raised, rather only checking for exceptions at the end. It fix following fatal error in fill_time(): Fatal Python error: _Py_CheckSlotResult: Slot * of type int succeeded with an exception set
* fixes gh-109559: Update `unicodedata` for Unicode 15.1.0 (GH-109560)James Gerity2023-09-203-17533/+17882
| | | | | --------- Co-authored-by: Benjamin Peterson <benjamin@python.org>
* gh-109033: Return filename with os.utime errors (#109034)Ronan Pigott2023-09-191-7/+2
| | | | | | | The filename was previously intentionally omitted from exception because "it might confuse the user". Uncaught exceptions are not generally a replacement for user-facing error messages, so obscuring this information only has the effect of making the programmer's life more difficult.
* gh-76785: Use Pending Calls When Releasing Cross-Interpreter Data (gh-109556)Eric Snow2023-09-192-28/+31
| | | This fixes some crashes in the _xxinterpchannels module, due to a race between interpreters.
* gh-108724: Add PyMutex and _PyParkingLot APIs (gh-109344)Sam Gross2023-09-196-2/+432
| | | | | | | | | | | | | | | | | | | | | | | | | | PyMutex is a one byte lock with fast, inlineable lock and unlock functions for the common uncontended case. The design is based on WebKit's WTF::Lock. PyMutex is built using the _PyParkingLot APIs, which provides a cross-platform futex-like API (based on WebKit's WTF::ParkingLot). This internal API will be used for building other synchronization primitives used to implement PEP 703, such as one-time initialization and events. This also includes tests and a mini benchmark in Tools/lockbench/lockbench.py to compare with the existing PyThread_type_lock. Uncontended acquisition + release: * Linux (x86-64): PyMutex: 11 ns, PyThread_type_lock: 44 ns * macOS (arm64): PyMutex: 13 ns, PyThread_type_lock: 18 ns * Windows (x86-64): PyMutex: 13 ns, PyThread_type_lock: 38 ns PR Overview: The primary purpose of this PR is to implement PyMutex, but there are a number of support pieces (described below). * PyMutex: A 1-byte lock that doesn't require memory allocation to initialize and is generally faster than the existing PyThread_type_lock. The API is internal only for now. * _PyParking_Lot: A futex-like API based on the API of the same name in WebKit. Used to implement PyMutex. * _PyRawMutex: A word sized lock used to implement _PyParking_Lot. * PyEvent: A one time event. This was used a bunch in the "nogil" fork and is useful for testing the PyMutex implementation, so I've included it as part of the PR. * pycore_llist.h: Defines common operations on doubly-linked list. Not strictly necessary (could do the list operations manually), but they come up frequently in the "nogil" fork. ( Similar to https://man.freebsd.org/cgi/man.cgi?queue) --------- Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
* gh-109469: Silence compiler warnings on string comparisons in _testcapi ↵Serhiy Storchaka2023-09-191-1/+2
| | | | (GH-109533)
* gh-102757: fix function signature mismatch for `functools.reduce` between ↵Xuehai Pan2023-09-181-1/+1
| | | | code and documentation (#102759)
* gh-109496: Detect Py_DECREF() after dealloc in debug mode (#109539)Victor Stinner2023-09-181-0/+21
| | | | | | | | | On a Python built in debug mode, Py_DECREF() now calls _Py_NegativeRefcount() if the object is a dangling pointer to deallocated memory: memory filled with 0xDD "dead byte" by the debug hook on memory allocators. The fix is to check the reference count *before* checking for _Py_IsImmortal(). Add test_decref_freed_object() to test_capi.test_misc.
* gh-108511: Add C API functions which do not silently ignore errors (GH-109025)Serhiy Storchaka2023-09-178-18/+65
| | | | | | | | | Add the following functions: * PyObject_HasAttrWithError() * PyObject_HasAttrStringWithError() * PyMapping_HasKeyWithError() * PyMapping_HasKeyStringWithError()
* Add missing `PyDoc_STR` calls (#109393)Nikita Sobolev2023-09-152-4/+4
| | | | | | | | | In files: * Modules/_ctypes/cfield.c * Modules/_struct.c * Objects/dictobject.c * Objects/typevarobject.c * Objects/unionobject.c
* gh-107782: Use _testcapi to test non-representable signatures (GH-109325)Serhiy Storchaka2023-09-141-0/+44
| | | | | | | | | Builtin functions and methods that have non-representable signatures today will have representable signatures yesterday, and they will become unusable for testing this feature. So we need to add special functions and methods to the _testcapi module that always have non-representable signatures.
* gh-108346: Fix failed benchmark in decimal (#108353)Charlie Zhao2023-09-131-53/+74
| | | Fix benchmark in decimal to work again after the int str conversion limits.
* gh-108987: Fix _thread.start_new_thread() race condition (#109135)Victor Stinner2023-09-111-16/+31
| | | | | | | | | | | | | Fix _thread.start_new_thread() race condition. If a thread is created during Python finalization, the newly spawned thread now exits immediately instead of trying to access freed memory and lead to a crash. thread_run() calls PyEval_AcquireThread() which checks if the thread must exit. The problem was that tstate was dereferenced earlier in _PyThreadState_Bind() which leads to a crash most of the time. Move _PyThreadState_CheckConsistency() from thread_run() to _PyThreadState_Bind().
* gh-109050: Remove remaining tests for legacy Unicode C API (GH-109068)Serhiy Storchaka2023-09-091-52/+0
|
* gh-104690: thread_run() checks for tstate dangling pointer (#109056)Victor Stinner2023-09-081-2/+5
| | | | | | | | thread_run() of _threadmodule.c now calls _PyThreadState_CheckConsistency() to check if tstate is a dangling pointer when Python is built in debug mode. Rename ceval_gil.c is_tstate_valid() to _PyThreadState_CheckConsistency() to reuse it in _threadmodule.c.
* GH-91079: Rename C_RECURSION_LIMIT to Py_C_RECURSION_LIMIT (#108507)Victor Stinner2023-09-082-0/+6
| | | | | | | Symbols of the C API should be prefixed by "Py_" to avoid conflict with existing names in 3rd party C extensions on "#include <Python.h>". test.pythoninfo now logs Py_C_RECURSION_LIMIT constant and other _testcapi and _testinternalcapi constants.
* gh-109045: Remove remaining LIMITED_API_AVAILABLE checks in tests (#109046)Anders Kaseorg2023-09-073-16/+0
| | | | | | | | | Commit 13a00078b81776b23b0b6add69b848382240d1f2 (#108663) made all Python builds compatible with the Limited API, and removed the LIMITED_API_AVAILABLE flag. However, some tests were still checking for that flag, so they were now being incorrectly skipped. Remove these checks to let these tests run again. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
* gh-107211: No longer export internal _PyLong_FromUid() (#109037)Victor Stinner2023-09-071-11/+17
| | | | No longer export _PyLong_FromUid() and _Py_Sigset_Converter() internal C API function.
* gh-108751: Add copy.replace() function (GH-108752)Serhiy Storchaka2023-09-061-0/+6
| | | | | | | | | It creates a modified copy of an object by calling the object's __replace__() method. It is a generalization of dataclasses.replace(), named tuple's _replace() method and replace() methods in various classes, and supports all these stdlib classes.
* C API tests: use special markers to test that output parameters were set ↵Serhiy Storchaka2023-09-067-30/+60
| | | | (GH-109014)
* gh-108753: Enhance pystats (#108754)Victor Stinner2023-09-061-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Statistics gathering is now off by default. Use the "-X pystats" command line option or set the new PYTHONSTATS environment variable to 1 to turn statistics gathering on at Python startup. Statistics are no longer dumped at exit if statistics gathering was off or statistics have been cleared. Changes: * Add PYTHONSTATS environment variable. * sys._stats_dump() now returns False if statistics are not dumped because they are all equal to zero. * Add PyConfig._pystats member. * Add tests on sys functions and on setting PyConfig._pystats to 1. * Add Include/cpython/pystats.h and Include/internal/pycore_pystats.h header files. * Rename '_py_stats' variable to '_Py_stats'. * Exclude Include/cpython/pystats.h from the Py_LIMITED_API. * Move pystats.h include from object.h to Python.h. * Add _Py_StatsOn() and _Py_StatsOff() functions. Remove '_py_stats_struct' variable from the API: make it static in specialize.c. * Document API in Include/pystats.h and Include/cpython/pystats.h. * Complete pystats documentation in Doc/using/configure.rst. * Don't write "all zeros" stats: if _stats_off() and _stats_clear() or _stats_dump() were called. * _PyEval_Fini() now always call _Py_PrintSpecializationStats() which does nothing if stats are all zeros. Co-authored-by: Michael Droettboom <mdboom@gmail.com>
* gh-108717: Speedup `os.DirEntry.is_junction` function (#108718)Nikita Sobolev2023-09-062-13/+7
|