summaryrefslogtreecommitdiffstats
path: root/Include
Commit message (Collapse)AuthorAgeFilesLines
* gh-110964: Remove private _PyArg functions (#110966)Victor Stinner2023-10-173-79/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move the following private functions and structures to pycore_modsupport.h internal C API: * _PyArg_BadArgument() * _PyArg_CheckPositional() * _PyArg_NoKeywords() * _PyArg_NoPositional() * _PyArg_ParseStack() * _PyArg_ParseStackAndKeywords() * _PyArg_Parser structure * _PyArg_UnpackKeywords() * _PyArg_UnpackKeywordsWithVararg() * _PyArg_UnpackStack() * _Py_ANY_VARARGS() Changes: * Python/getargs.h now includes pycore_modsupport.h to export functions. * clinic.py now adds pycore_modsupport.h when one of these functions is used. * Add pycore_modsupport.h includes when a C extension uses one of these functions. * Define Py_BUILD_CORE_MODULE in C extensions which now include directly or indirectly (via code generated by Argument Clinic) pycore_modsupport.h: * _csv * _curses_panel * _dbm * _gdbm * _multiprocessing.posixshmem * _sqlite.row * _statistics * grp * resource * syslog * _testcapi: bad_get() no longer uses METH_FASTCALL calling convention but METH_VARARGS. Replace _PyArg_UnpackStack() with PyArg_ParseTuple(). * _testcapi: add PYTESTCAPI_NEED_INTERNAL_API macro which is defined by _testcapi sub-modules which need the internal C API (pycore_modsupport.h): exceptions.c, float.c, vectorcall.c, watchers.c. * Remove Include/cpython/modsupport.h header file. Include/modsupport.h no longer includes the removed header file. * Fix mypy clinic.py
* gh-110968: Py_MOD_PER_INTERPRETER_GIL_SUPPORTED new in 3.13. (#110969)Victor Stinner2023-10-171-2/+4
| | | | | | | | | | * Only add Py_MOD_PER_INTERPRETER_GIL_SUPPORTED to limited C API version 3.13. * errno, xxlimited and _ctypes_test extensions now need the limited C API version 3.13 to get Py_MOD_PER_INTERPRETER_GIL_SUPPORTED. They now include standard header files explicitly: <errno.h>, <string.h> and <stdio.h>. * xxlimited_35: Remove Py_mod_multiple_interpreters slot, incompatible with limited C API version 3.5.
* gh-85283: Add PyMem_RawMalloc() to the limited C API (#108570)Victor Stinner2023-10-172-6/+11
| | | | | | | | | Add PyMem_RawMalloc(), PyMem_RawCalloc(), PyMem_RawRealloc() and PyMem_RawFree() to the limited C API. These functions were added by Python 3.4 and are needed to port stdlib extensions to the limited C API, like grp and pwd. Co-authored-by: Erlend E. Aasland <erlend@python.org>
* gh-109693: Update _gil_runtime_state.locked to use pyatomic.h (gh-110836)Donghee Na2023-10-165-2/+58
|
* gh-107450: Check for overflow in the tokenizer and fix overflow test (#110832)Lysandros Nikolaou2023-10-161-18/+19
| | | | Co-authored-by: Filipe Laíns <lains@riseup.net> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-110722: Add PYTHON_PRESITE to import a module before site.py is run (#110769)Łukasz Langa2023-10-141-0/+6
|
* gh-109693: Update pyruntimestate._finalizing to use pyatomic.h (gh-110837)Donghee Na2023-10-131-4/+3
|
* Merge branch 'main' of https://github.com/python/cpythonThomas Wouters2023-10-132-1/+12
|\
| * gh-110805: Allow the repl to show source code and complete tracebacks (#110775)Pablo Galindo Salgado2023-10-132-1/+12
| |
* | Post 3.13.0a1Thomas Wouters2023-10-131-1/+1
| |
* | Python 3.13.0a1v3.13.0a1Thomas Wouters2023-10-131-2/+2
|/
* gh-109693: Update _gil_runtime_state.last_holder to use pyatomic.h (#110605)Donghee Na2023-10-131-2/+2
|
* gh-110721: Use the traceback module for PyErr_Display() and fallback to the ↵Pablo Galindo Salgado2023-10-121-3/+2
| | | | C implementation (#110702)
* gh-109094: remove redundant arg to _PyFrame_PushTrampolineUnchecked (GH-110759)Irit Katriel2023-10-121-2/+2
|
* GH-109214: Convert _SAVE_CURRENT_IP to _SET_IP in tier 2 trace creation. ↵Mark Shannon2023-10-121-4/+4
| | | | (GH-110755)
* gh-85283: If Py_LIMITED_API is defined, undefine Py_BUILD_CORE (#110725)Victor Stinner2023-10-111-4/+9
| | | | | | | | | | | If the Py_LIMITED_API macro is defined, Py_BUILD_CORE, Py_BUILD_CORE_BUILTIN and Py_BUILD_CORE_MODULE macros are now undefined by Python.h. Only undefine these 3 macros after including "exports.h" which uses them to define PyAPI_FUNC(), PyAPI_DATA() and PyMODINIT_FUNC macros. Remove hacks (undefine manually the 3 Py_BUILD_CORE macros) in Modules/_testcapi/parts.h and Modules/_testclinic_limited.c.
* gh-110289: C API: Add PyUnicode_EqualToUTF8() and ↵Serhiy Storchaka2023-10-111-0/+9
| | | | PyUnicode_EqualToUTF8AndSize() functions (GH-110297)
* gh-109693: Update pycore_interp.h to use pyatomic.h (#110604)Donghee Na2023-10-101-4/+3
|
* gh-109595: Add -Xcpu_count=<n> cmdline for container users (#109667)Donghee Na2023-10-101-0/+2
| | | | | | --------- Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
* gh-109693: Use pyatomic.h for signal module (gh-110480)Donghee Na2023-10-091-9/+7
|
* gh-76785: Add SendChannel.send_buffer() (#110246)Eric Snow2023-10-094-2/+39
| | | (This is still a test module.)
* gh-108277: Add os.timerfd_create() function (#108382)Masaru Tsuchiyama2023-10-075-1/+11
| | | | | | | | Add wrapper for timerfd_create, timerfd_settime, and timerfd_gettime to os module. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-110397: Add Py_IsFinalizing() to the stable ABI (#110441)Victor Stinner2023-10-072-2/+4
|
* gh-85283: Add PySys_AuditTuple() function (#108965)Victor Stinner2023-10-051-1/+5
| | | | | | sys.audit() now has assertions to check that the event argument is not NULL and that the format argument does not use the "N" format. Add tests on PySys_AuditTuple().
* gh-109549: Add new states to PyThreadState to support PEP 703 (gh-109915)Sam Gross2023-10-053-1/+46
| | | This adds a new field 'state' to PyThreadState that can take on one of three values: _Py_THREAD_ATTACHED, _Py_THREAD_DETACHED, or _Py_THREAD_GC. The "attached" and "detached" states correspond closely to acquiring and releasing the GIL. The "gc" state is current unused, but will be used to implement stop-the-world GC for --disable-gil builds in the near future.
* gh-109329: Add stat for "trace too short" (GH-110402)Michael Droettboom2023-10-051-0/+1
|
* gh-88402: Add new sysconfig variables on Windows (GH-110049)Sam Gross2023-10-041-0/+57
| | | | Co-authored-by: Filipe Laíns <filipe.lains@gmail.com>
* gh-110310: Add a Per-Interpreter XID Registry for Heap Types (gh-110311)Eric Snow2023-10-042-19/+30
| | | | | | | | | | | We do the following: * add a per-interpreter XID registry (PyInterpreterState.xidregistry) * put heap types there (keep static types in _PyRuntimeState.xidregistry) * clear the registries during interpreter/runtime finalization * avoid duplicate entries in the registry (when _PyCrossInterpreterData_RegisterClass() is called more than once for a type) * use Py_TYPE() instead of PyObject_Type() in _PyCrossInterpreterData_Lookup() The per-interpreter registry helps preserve isolation between interpreters. This is important when heap types are registered, which is something we haven't been doing yet but I will likely do soon.
* GH-109329: Add tier 2 stats (GH-109913)Michael Droettboom2023-10-042-4/+39
|
* GH-109369: Merge all eval-breaker flags and monitoring version into one ↵Mark Shannon2023-10-044-18/+39
| | | | word. (GH-109846)
* gh-104909: Split more LOAD_ATTR specializations (GH-110317)Guido van Rossum2023-10-041-35/+111
| | | | | | | | | | | | | | | | | | | * Split LOAD_ATTR_MODULE * Split LOAD_ATTR_WITH_HINT * Split _GUARD_TYPE_VERSION out of the latter * Split LOAD_ATTR_CLASS * Split LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES * Fix indent of DEOPT_IF in macros * Split LOAD_ATTR_METHOD_LAZY_DICT * Split LOAD_ATTR_NONDESCRIPTOR_NO_DICT * Fix omission of _CHECK_ATTR_METHOD_LAZY_DICT
* gh-109979: Unify _GUARD_TYPE_VERSION{,_STORE} (#110301)Guido van Rossum2023-10-031-39/+32
| | | | | Now the target for `DEOPT_IF()` is auto-filled, we don't need a separate `_GUARD_TYPE_VERSION_STORE` uop.
* gh-108867: Add PyThreadState_GetUnchecked() function (#108870)Victor Stinner2023-10-034-4/+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-033-1/+14
| | | | | | | | | 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-105716: Support Background Threads in Subinterpreters Consistently ↵Eric Snow2023-10-023-0/+8
| | | | | | | (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-0/+3
| | | 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-021-2/+2
| | | | | | | | 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-110014: Remove PY_TIMEOUT_MAX from limited C API (#110217)Victor Stinner2023-10-022-13/+12
| | | | | | | | If the timeout is greater than PY_TIMEOUT_MAX, PyThread_acquire_lock_timed() uses a timeout of PY_TIMEOUT_MAX microseconds, which is around 280.6 years. This case is unlikely and limiting a timeout to 280.6 years sounds like a reasonable trade-off. The constant PY_TIMEOUT_MAX is not used in PyPI top 5,000 projects.
* gh-110014: Include explicitly <unistd.h> header (#110155)Victor Stinner2023-09-302-8/+25
| | | | | | | | | | | * 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-110014: Fix _POSIX_THREADS and _POSIX_SEMAPHORES usage (#110139)Victor Stinner2023-09-304-51/+28
| | | | | | | | | | | | | | | | * pycore_pythread.h is now the central place to make sure that _POSIX_THREADS and _POSIX_SEMAPHORES macros are defined if available. * Make sure that pycore_pythread.h is included when _POSIX_THREADS and _POSIX_SEMAPHORES macros are tested. * PY_TIMEOUT_MAX is now defined as a constant, since its value depends on _POSIX_THREADS, instead of being defined as a macro. * Prevent integer overflow in the preprocessor when computing PY_TIMEOUT_MAX_VALUE on Windows: replace "0xFFFFFFFELL * 1000 < LLONG_MAX" with "0xFFFFFFFELL < LLONG_MAX / 1000". * Document the change and give hints how to fix affected code. * Add an exception for PY_TIMEOUT_MAX name to smelly.py * Add PY_TIMEOUT_MAX to the stable ABI
* gh-110024: Fix Pointer Type Warnings (gh-110053)Eric Snow2023-09-291-8/+16
| | | The warnings were introduced by gh-109794 (for gh-109793).
* gh-104909: Split some more insts into ops (#109943)Guido van Rossum2023-09-272-27/+95
| | | | | | | | | | | | | | | | | | | | These are the most popular specializations of `LOAD_ATTR` and `STORE_ATTR` that weren't already viable uops: * Split LOAD_ATTR_METHOD_WITH_VALUES * Split LOAD_ATTR_METHOD_NO_DICT * Split LOAD_ATTR_SLOT * Split STORE_ATTR_SLOT * Split STORE_ATTR_INSTANCE_VALUE Also: * Add `-v` flag to code generator which prints a list of non-viable uops (easter-egg: it can print execution counts -- see source) * Double _Py_UOP_MAX_TRACE_LENGTH to 128 I had dropped one of the DEOPT_IF() calls! :-(
* gh-109793: Allow Switching Interpreters During Finalization (gh-109794)Eric Snow2023-09-274-2/+55
| | | Essentially, we should check the thread ID rather than the thread state pointer.
* gh-109611: Add convenient C API function _PyFile_Flush() (GH-109612)Serhiy Storchaka2023-09-231-0/+2
|
* gh-109596: Ensure repeated rules in the grammar are not allowed and fix ↵Pablo Galindo Salgado2023-09-221-3/+0
| | | | incorrect soft keywords (#109606)
* gh-104469: Disallow using Py_LIMITED_API with Py_BUILD_CORE (#109690)Victor Stinner2023-09-211-0/+4
| | | | Fix make check-c-globals: complete USE_LIMITED_C_API list of the c-analyzer.
* gh-109693: Remove pycore_atomic_funcs.h (#109694)Sam Gross2023-09-211-94/+0
| | | _PyUnicode_FromId() now uses pyatomic.h functions instead.
* gh-76785: Use Pending Calls When Releasing Cross-Interpreter Data (gh-109556)Eric Snow2023-09-193-2/+5
| | | This fixes some crashes in the _xxinterpchannels module, due to a race between interpreters.
* gh-108724: Fix _PySemaphore compile error on WASM (gh-109583)Sam Gross2023-09-191-1/+2
| | | Some WASM platforms have POSIX semaphores, but not sem_timedwait.
* gh-108724: Add PyMutex and _PyParkingLot APIs (gh-109344)Sam Gross2023-09-198-7/+448
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>