summaryrefslogtreecommitdiffstats
path: root/Python/sysmodule.c
Commit message (Collapse)AuthorAgeFilesLines
* gh-118335: Configure Tier 2 interpreter at build time (#118339)Guido van Rossum2024-05-011-0/+2
| | | | | | | | | | | | | | | | | | | | | | The code for Tier 2 is now only compiled when configured with `--enable-experimental-jit[=yes|interpreter]`. We drop support for `PYTHON_UOPS` and -`Xuops`, but you can disable the interpreter or JIT at runtime by setting `PYTHON_JIT=0`. You can also build it without enabling it by default using `--enable-experimental-jit=yes-off`; enable with `PYTHON_JIT=1`. On Windows, the `build.bat` script supports `--experimental-jit`, `--experimental-jit-off`, `--experimental-interpreter`. In the C code, `_Py_JIT` is defined as before when the JIT is enabled; the new variable `_Py_TIER2` is defined when the JIT *or* the interpreter is enabled. It is actually a bitmask: 1: JIT; 2: default-off; 4: interpreter.
* gh-117953: Cleanups For fix_up_extension() in import.c (gh-118192)Eric Snow2024-04-241-1/+1
| | | These are cleanups I've pulled out of gh-118116. Mostly, this change moves code around to align with some future changes and to improve clarity a little. There is one very small change in behavior: we now add the module to the per-interpreter caches after updating the global state, rather than before.
* gh-117987: Restore several functions removed in Python 3.13 alpha 1 (GH-117993)Victor Stinner2024-04-181-4/+2
| | | | | | | | | Restore these functions removed in Python 3.13 alpha 1: * Py_SetPythonHome() * Py_SetProgramName() * PySys_SetArgvEx() * PySys_SetArgv()
* gh-117764: Add signatures for some functions in the sys module (GH-117770)Serhiy Storchaka2024-04-121-30/+44
| | | Use Argument Clinic if possible.
* gh-116167: Allow disabling the GIL with `PYTHON_GIL=0` or `-X gil=0` (#116338)Brett Simmers2024-03-111-0/+11
| | | | | | | | | In free-threaded builds, running with `PYTHON_GIL=0` will now disable the GIL. Follow-up issues track work to re-enable the GIL when loading an incompatible extension, and to disable the GIL by default. In order to support re-enabling the GIL at runtime, all GIL-related data structures are initialized as usual, and disabling the GIL simply sets a flag that causes `take_gil()` and `drop_gil()` to return early.
* gh-116326: Handler errors correctly in `getwindowsversion` in `sysmodule` ↵Nikita Sobolev2024-03-051-20/+32
| | | | (#116339)
* gh-115320: Refactor `get_hash_info` in `sysmodule.c` not to swallow errors ↵Nikita Sobolev2024-03-041-23/+25
| | | | (#115321)
* gh-115168: Add pystats counter for invalidated executors (GH-115169)Michael Droettboom2024-02-261-1/+1
|
* GH-114695: Add `sys._clear_internal_caches` (GH-115152)Brandt Bucher2024-02-121-0/+17
|
* gh-112529: Remove PyGC_Head from object pre-header in free-threaded build ↵Sam Gross2024-02-011-1/+9
| | | | | | | | | | | | | | | | | (#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-114384: Align sys.set_asyncgen_hooks signature in docs to reflect ↵Nikita Sobolev2024-01-211-1/+1
| | | | implementation (#114385)
* gh-73427: deprecate `_enablelegacywindowsfsencoding` (#107729)Inada Naoki2023-12-281-0/+7
|
* gh-111924: Use PyMutex for Runtime-global Locks. (gh-112207)Sam Gross2023-12-071-9/+3
| | | | | This replaces some usages of PyThread_type_lock with PyMutex, which does not require memory allocation to initialize. This simplifies some of the runtime initialization and is also one step towards avoiding changing the default raw memory allocator during initialize/finalization, which can be non-thread-safe in some circumstances.
* bpo-34392: Add sys. _is_interned() (GH-8755)Serhiy Storchaka2023-12-041-0/+18
|
* gh-111262: Add PyDict_Pop() function (#112028)Victor Stinner2023-11-141-3/+1
| | | | | | | _PyDict_Pop_KnownHash(): remove the default value and the return type becomes an int. Co-authored-by: Stefan Behnel <stefan_ml@behnel.de> Co-authored-by: Antoine Pitrou <pitrou@free.fr>
* gh-106672: C API: Report indiscriminately ignored errors (GH-106674)Serhiy Storchaka2023-11-071-0/+3
| | | | | Functions which indiscriminately ignore all errors now report them as unraisable errors.
* gh-109587: Allow "precompiled" perf-trampolines to largely mitigate the cost ↵gsallam2023-10-271-1/+40
| | | | of enabling perf-trampolines (#109666)
* gh-109595: Add -Xcpu_count=<n> cmdline for container users (#109667)Donghee Na2023-10-101-0/+15
| | | | | | --------- Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
* gh-85283: Add PySys_AuditTuple() function (#108965)Victor Stinner2023-10-051-3/+19
| | | | | | 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-110014: Include explicitly <unistd.h> header (#110155)Victor Stinner2023-09-301-1/+3
| | | | | | | | | | | * 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-110079: Remove extern "C" { ...} in C code (#110080)Victor Stinner2023-09-291-18/+0
|
* Fix error handling in _PySys_UpdateConfig() (GH-109524)Serhiy Storchaka2023-09-181-2/+9
|
* gh-108753: Enhance pystats (#108754)Victor Stinner2023-09-061-12/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-108765: Cleanup #include in Python/*.c files (#108977)Victor Stinner2023-09-061-7/+9
| | | Mention one symbol imported by each #include.
* gh-106320: Remove private _PySys functions (#108452)Victor Stinner2023-08-241-0/+1
| | | | | | | | | | Move private functions to the internal C API (pycore_sysmodule.h): * _PySys_GetAttr() * _PySys_GetSizeOf() No longer export most of these functions. Fix also a typo in Include/cpython/optimizer.h: add a missing space.
* gh-108308: Remove _PyDict_GetItemStringWithError() function (#108426)Victor Stinner2023-08-241-1/+6
| | | | | | | | Remove the internal _PyDict_GetItemStringWithError() function. It can now be replaced with the new public PyDict_ContainsString() and PyDict_GetItemStringRef() functions. getargs.c now now uses a strong reference for current_arg. find_keyword() returns a strong reference.
* gh-108014: Add Py_IsFinalizing() function (#108032)Victor Stinner2023-08-181-1/+1
| | | Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* GH-108035: Remove the `_PyCFrame` struct as it is no longer needed for ↵Mark Shannon2023-08-171-2/+2
| | | | performance. (GH-108036)
* gh-106320: Remove private _PyDict C API (#107145)Victor Stinner2023-07-241-0/+1
| | | | | | | | | | | | | Move private _PyDict functions to the internal C API (pycore_dict.h): * _PyDict_Contains_KnownHash() * _PyDict_DebugMallocStats() * _PyDict_DelItemIf() * _PyDict_GetItemWithError() * _PyDict_HasOnlyStringKeys() * _PyDict_MaybeUntrack() * _PyDict_MergeEx() No longer export these functions.
* gh-106320: Remove private _PyObject C API (#107147)Victor Stinner2023-07-231-1/+1
| | | | | | | | | | | | | | | | Move private debug _PyObject functions to the internal C API (pycore_object.h): * _PyDebugAllocatorStats() * _PyObject_CheckConsistency() * _PyObject_DebugTypeStats() * _PyObject_IsFreed() No longer export most of these functions, except of _PyObject_IsFreed(). Move test functions using _PyObject_IsFreed() from _testcapi to _testinternalcapi. check_pyobject_is_freed() test no longer catch _testcapi.error: the tested function cannot raise _testcapi.error.
* gh-106521: Remove _PyObject_LookupAttr() function (GH-106642)Serhiy Storchaka2023-07-121-2/+2
|
* gh-106320: Create pycore_modsupport.h header file (#106355)Victor Stinner2023-07-031-0/+1
| | | | | | | | | | Remove the following functions from the C API, move them to the internal C API: add a new pycore_modsupport.h internal header file: * PyModule_CreateInitialized() * _PyArg_NoKwnames() * _Py_VaBuildStack() No longer export these functions.
* gh-106023: Remove _PyObject_FastCallTstate() function (#106273)Victor Stinner2023-06-301-7/+5
|
* gh-106182: sys: Intern getfilesystemencoding() and ↵Inada Naoki2023-06-301-5/+25
| | | | | getfilesystemencodeerrors() (#106183) sys: Intern getfilesystemencoding() and getfilesystemencodeerrors()
* fix typos (#106247)Inada Naoki2023-06-301-1/+1
| | | Most typos are in comments, but two typos are in docstring.
* gh-106023: Update code using _PyObject_FastCall() (#106257)Victor Stinner2023-06-301-1/+1
| | | Replace _PyObject_FastCall() calls with PyObject_Vectorcall().
* gh-106118: Add O_CLOEXEC preprocessor guard (#106120)Erlend E. Aasland2023-06-281-1/+4
|
* gh-106084: Remove old PyObject call aliases (#106085)Victor Stinner2023-06-261-1/+1
| | | | | | | | | | | | | | Remove old aliases which were kept backwards compatibility with Python 3.8: * _PyObject_CallMethodNoArgs() * _PyObject_CallMethodOneArg() * _PyObject_CallOneArg() * _PyObject_FastCallDict() * _PyObject_Vectorcall() * _PyObject_VectorcallMethod() * _PyVectorcall_Function() Update code which used these aliases to use new names.
* gh-105673: Fix uninitialized warning in sysmodule.c (#105674)Nikita Sobolev2023-06-121-1/+1
| | | In sys_add_xoption(), 'value' may be uninitialized for some error paths.
* gh-105375: Improve error handling in the sys extension module (#105611)Erlend E. Aasland2023-06-111-6/+18
| | | | | In _PySys_AddXOptionWithError() and sys_add_xoption(), bail on first error to prevent exceptions from possibly being overwritten.
* gh-100227: Lock Around Adding Global Audit Hooks (gh-105515)Eric Snow2023-06-081-17/+39
| | | The risk of a race with this state is relatively low, but we play it safe anyway.
* gh-105145: Remove old functions to config Python init (#105154)Victor Stinner2023-06-011-7/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove the following old functions to configure the Python initialization, deprecated in Python 3.11: * PySys_AddWarnOptionUnicode() * PySys_AddWarnOption() * PySys_AddXOption() * PySys_HasWarnOptions() * PySys_SetArgvEx() * PySys_SetArgv() * PySys_SetPath() * Py_SetPath() * Py_SetProgramName() * Py_SetPythonHome() * Py_SetStandardStreamEncoding() * _Py_SetProgramFullPath() Most of these functions are kept in the stable ABI, except: * Py_SetStandardStreamEncoding() * _Py_SetProgramFullPath() Update Doc/extending/embedding.rst and Doc/extending/extending.rst to use the new PyConfig API. _testembed.c: * check_stdio_details() now sets stdio_encoding and stdio_errors of PyConfig. * Add definitions of functions removed from the API but kept in the stable ABI. * test_init_from_config() and test_init_read_set() now use PyConfig_SetString() instead of PyConfig_SetBytesString(). Remove _Py_ClearStandardStreamEncoding() internal function.
* gh-104922: Make `PY_SSIZE_T_CLEAN` not mandatory again (#105051)Inada Naoki2023-05-311-1/+1
|
* gh-103295: expose API for writing perf map files (#103546)gsallam2023-05-211-1/+79
| | | | | Co-authored-by: Aniket Panse <aniketpanse@fb.com> Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Carl Meyer <carl@oddbird.net>
* GH-102818: Do not call `PyTraceBack_Here` in sys.settrace trampoline. ↵Mark Shannon2023-05-191-4/+0
| | | | (GH-104579)
* gh-104341: Adjust tstate_must_exit() to Respect Interpreter Finalization ↵Eric Snow2023-05-151-0/+4
| | | | | (gh-104437) With the move to a per-interpreter GIL, this check slipped through the cracks.
* gh-103323: Remove PyRuntimeState_GetThreadState() (#104171)Victor Stinner2023-05-041-1/+1
| | | | | This function no longer makes sense, since its runtime parameter is no longer used. Use directly _PyThreadState_GET() and _PyInterpreterState_GET() instead.
* gh-94673: Properly Initialize and Finalize Static Builtin Types for Each ↵Eric Snow2023-05-021-12/+16
| | | | | Interpreter (gh-104072) Until now, we haven't been initializing nor finalizing the per-interpreter state properly.
* gh-84436: Immortalize in _PyStructSequence_InitBuiltinWithFlags() (gh-104054)Eric Snow2023-05-011-5/+5
| | | This also does some cleanup.
* gh-94673: Ensure Builtin Static Types are Readied Properly (gh-103940)Eric Snow2023-04-271-14/+8
| | | There were cases where we do unnecessary work for builtin static types. This also simplifies some work necessary for a per-interpreter GIL.