summaryrefslogtreecommitdiffstats
path: root/Modules/_testcapimodule.c
Commit message (Collapse)AuthorAgeFilesLines
* gh-104614: Fix potential ref. leak in ↵Erlend E. Aasland2023-06-021-1/+3
| | | | _testcapimodule/get_basic_static_type() (#105225)
* gh-104614: Make Sure ob_type is Always Set Correctly by PyType_Ready() ↵Eric Snow2023-06-011-0/+45
| | | | | | | (gh-105122) When I added the relevant condition to type_ready_set_bases() in gh-103912, I had missed that the function also sets tp_base and ob_type (if necessary). That led to problems for third-party static types. We fix that here, by making those extra operations distinct and by adjusting the condition to be more specific.
* gh-105107: Remove PyCFunction_Call() function (#105181)Victor Stinner2023-06-011-0/+14
| | | | | * Keep the function in the stable ABI. * Add unit tests on PyCFunction_Call() since it remains supported in the stable ABI.
* gh-104922: Make `PY_SSIZE_T_CLEAN` not mandatory again (#105051)Inada Naoki2023-05-311-47/+0
|
* gh-105020: Share tp_bases and tp_mro Between Interpreters For All Static ↵Eric Snow2023-05-311-0/+23
| | | | | Builtin Types (gh-105115) In gh-103912 we added tp_bases and tp_mro to each PyInterpreterState.types.builtins entry. However, doing so ignored the fact that both PyTypeObject fields are public API, and not documented as internal (as opposed to tp_subclasses). We address that here by reverting back to shared objects, making them immortal in the process.
* gh-104645: fix error handling in marshal tests (#104646)Irit Katriel2023-05-191-18/+14
|
* GH-102818: Do not call `PyTraceBack_Here` in sys.settrace trampoline. ↵Mark Shannon2023-05-191-0/+28
| | | | (GH-104579)
* gh-93649: Split gc- and allocation tests from _testcapimodule.c (GH-104403)Jurica Bradarić2023-05-121-326/+3
|
* gh-99113: Add PyInterpreterConfig.own_gil (gh-104204)Eric Snow2023-05-051-2/+10
| | | | | We also add PyInterpreterState.ceval.own_gil to record if the interpreter actually has its own GIL. Note that for now we don't actually respect own_gil; all interpreters still share the one GIL. However, PyInterpreterState.ceval.own_gil does reflect PyInterpreterConfig.own_gil. That lie is a temporary one that we will fix when the GIL really becomes per-interpreter.
* gh-104190: fix ubsan crash (#104191)sunmy20192023-05-051-1/+1
|
* gh-99593: Add tests for Unicode C API (part 2) (#99868)Serhiy Storchaka2023-05-041-0/+1
| | | | | Add tests for lower-level functions. Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
* gh-102500: Implement PEP 688 (#102521)Jelle Zijlstra2023-05-041-1/+3
| | | Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
* gh-103509: PEP 697 -- Limited C API for Extending Opaque Types (GH-103511)Petr Viktorin2023-05-041-0/+3
| | | | Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* gh-104109: Expose Py_NewInterpreterFromConfig() in the Public C-API (gh-104110)Eric Snow2023-05-031-2/+2
| | | | | We also expose PyInterpreterConfig. This is part of the PEP 684 (per-interpreter GIL) implementation. We will add docs as soon as we can. FYI, I'm adding the new config field for per-interpreter GIL in gh-99114.
* gh-84436: Add integration C API tests for immortal objects (gh-103962)Dong-hee Na2023-05-021-0/+3
|
* gh-103743: Add PyUnstable_Object_GC_NewWithExtraData (GH-103744)Jurica Bradarić2023-05-021-1/+104
| | | | Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* gh-101659: Isolate "obmalloc" State to Each Interpreter (gh-101660)Eric Snow2023-04-241-2/+10
| | | | | | | | | | | | | | This is strictly about moving the "obmalloc" runtime state from `_PyRuntimeState` to `PyInterpreterState`. Doing so improves isolation between interpreters, specifically most of the memory (incl. objects) allocated for each interpreter's use. This is important for a per-interpreter GIL, but such isolation is valuable even without it. FWIW, a per-interpreter obmalloc is the proverbial canary-in-the-coalmine when it comes to the isolation of objects between interpreters. Any object that leaks (unintentionally) to another interpreter is highly likely to cause a crash (on debug builds at least). That's a useful thing to know, relative to interpreter isolation.
* gh-103091: Add PyUnstable_Type_AssignVersionTag (#103095)Brett Simmers2023-04-241-0/+13
|
* gh-101659: Add _Py_AtExit() (gh-103298)Eric Snow2023-04-061-0/+32
| | | | | The function is like Py_AtExit() but for a single interpreter. This is a companion to the atexit module's register() function, taking a C callback instead of a Python one. We also update the _xxinterpchannels module to use _Py_AtExit(), which is the motivating case. (This is inspired by pain points felt while working on gh-101660.)
* GH-94808: Cover `PyOS_mystrnicmp` and `PyOS_mystricmp` (gh-102469)Artem Mukhin2023-03-221-0/+3
|
* gh-98608: Stop Treating All Errors from _Py_NewInterpreterFromConfig() as ↵Eric Snow2023-03-211-2/+6
| | | | | | | Fatal (gh-102657) Prior to this change, errors in _Py_NewInterpreterFromConfig() were always fatal. Instead, callers should be able to handle such errors and keep going. That's what this change supports. (This was an oversight in the original implementation of _Py_NewInterpreterFromConfig().) Note that the existing [fatal] behavior of the public Py_NewInterpreter() is preserved. https://github.com/python/cpython/issues/98608
* gh-102013: Add PyUnstable_GC_VisitObjects (#102014)Jacob Bower2023-03-141-0/+69
|
* gh-102304: Consolidate Direct Usage of _Py_RefTotal (gh-102514)Eric Snow2023-03-081-6/+1
| | | | | This simplifies further changes to _Py_RefTotal (e.g. make it atomic or move it to PyInterpreterState). https://github.com/python/cpython/issues/102304
* gh-101101: Unstable C API tier (PEP 689) (GH-101102)Petr Viktorin2023-02-281-0/+3
|
* gh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives ↵Irit Katriel2023-02-241-4/+3
| | | | (in Modules/) (#102196)
* gh-93649: Split exception tests from _testcapimodule.c (GH-102173)Erlend E. Aasland2023-02-231-287/+3
| | | Automerge-Triggered-By: GH:erlend-aasland
* GH-100719: Remove redundant `gi_code` field from generator object. (GH-100749)Mark Shannon2023-02-231-0/+11
|
* gh-98627: Add an Optional Check for Extension Module Subinterpreter ↵Eric Snow2023-02-161-2/+10
| | | | | | | | | | | | | | | Compatibility (gh-99040) Enforcing (optionally) the restriction set by PEP 489 makes sense. Furthermore, this sets the stage for a potential restriction related to a per-interpreter GIL. This change includes the following: * add tests for extension module subinterpreter compatibility * add _PyInterpreterConfig.check_multi_interp_extensions * add Py_RTFLAGS_MULTI_INTERP_EXTENSIONS * add _PyImport_CheckSubinterpIncompatibleExtensionAllowed() * fail iff the module does not implement multi-phase init and the current interpreter is configured to check https://github.com/python/cpython/issues/98627
* gh-101819: Remove _testcapi dependencies on specific _io symbols (#101918)Erlend E. Aasland2023-02-151-2/+6
|
* GH-101578: Normalize the current exception (GH-101607)Mark Shannon2023-02-081-0/+37
| | | | | | | | | | * Make sure that the current exception is always normalized. * Remove redundant type and traceback fields for the current exception. * Add new API functions: PyErr_GetRaisedException, PyErr_SetRaisedException * Add new API functions: PyException_GetArgs, PyException_SetArgs
* gh-101656: Fix "conversion from Py_ssize_t to int" warning in ↵Nikita Sobolev2023-02-071-3/+3
| | | | `_testcapimodule` (#101657)
* gh-101072: support default and kw default in PyEval_EvalCodeEx for 3.11+ ↵Matthieu Dartiailh2023-02-071-1/+140
| | | | | (#101127) Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* gh-59956: Add a Test to Verify GILState Matches the "Current" Thread State ↵Eric Snow2023-02-061-0/+37
| | | | | | | (gh-101625) This test should have been in gh-101431. https://github.com/python/cpython/issues/59956
* gh-101524: Split Up the _xxsubinterpreters Module (gh-101526)Eric Snow2023-02-041-0/+54
| | | | | This is step 1 in potentially dropping all the "channel"-related code. Channels have already been removed from PEP 554. https://github.com/python/cpython/issues/101524
* gh-101152: Implement PEP 699 (GH-101193)ram vikram singh2023-01-241-0/+3
| | | | Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Co-authored-by: Ken Jin <kenjin@python.org>
* GH-100892: Fix race in clearing `threading.local` (#100922)Kumar Aditya2023-01-111-5/+36
|
* gh-100228: Warn from os.fork() if other threads exist. (#100229)Gregory P. Smith2022-12-291-0/+47
| | | | | Not comprehensive, best effort warning. There are cases when threads exist on some platforms that this code cannot detect. macOS when API permissions allow and Linux with a readable /proc procfs present are the currently supported cases where a warning should show up reliably. Starting with a DeprecationWarning for now, it is less disruptive than something like RuntimeWarning and most likely to only be seen in people's CI tests - a good place to start with this messaging.
* gh-99110: Initialize `frame->previous` in init_frame to fix segmentation ↵Bill Fisher2022-12-231-0/+18
| | | | fault when accessing `frame.f_back` (#100182)
* gh-93649: Split tracemalloc tests from _testcapimodule.c (#99551)Erlend E. Aasland2022-12-171-75/+0
|
* gh-98724: Fix Py_CLEAR() macro side effects (#99100) (#100070)Victor Stinner2022-12-071-0/+87
| | | | | | | | | | | | | | The Py_CLEAR(), Py_SETREF() and Py_XSETREF() macros now only evaluate their arguments once. If an argument has side effects, these side effects are no longer duplicated. Use temporary variables to avoid duplicating side effects of macro arguments. If available, use _Py_TYPEOF() to avoid type punning. Otherwise, use memcpy() for the assignment to prevent a miscompilation with strict aliasing caused by type punning. Add _Py_TYPEOF() macro: __typeof__() on GCC and clang. Add test_py_clear() and test_py_setref() unit tests to _testcapi.
* Revert "gh-98724: Fix Py_CLEAR() macro side effects" (#99737)Victor Stinner2022-11-241-87/+0
| | | | | Revert "gh-98724: Fix Py_CLEAR() macro side effects (#99100)" This reverts commit c03e05c2e72f3ea5e797389e7d1042eef85ad37a.
* gh-47146: Soft-deprecate structmember.h, expose its contents via Python.h ↵Petr Viktorin2022-11-221-147/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (GH-99014) The ``structmember.h`` header is deprecated, though it continues to be available and there are no plans to remove it. There are no deprecation warnings. Old code can stay unchanged (unless the extra include and non-namespaced macros bother you greatly). Specifically, no uses in CPython are updated -- that would just be unnecessary churn. The ``structmember.h`` header is deprecated, though it continues to be available and there are no plans to remove it. Its contents are now available just by including ``Python.h``, with a ``Py`` prefix added if it was missing: - `PyMemberDef`, `PyMember_GetOne` and`PyMember_SetOne` - Type macros like `Py_T_INT`, `Py_T_DOUBLE`, etc. (previously ``T_INT``, ``T_DOUBLE``, etc.) - The flags `Py_READONLY` (previously ``READONLY``) and `Py_AUDIT_READ` (previously all uppercase) Several items are not exposed from ``Python.h``: - `T_OBJECT` (use `Py_T_OBJECT_EX`) - `T_NONE` (previously undocumented, and pretty quirky) - The macro ``WRITE_RESTRICTED`` which does nothing. - The macros ``RESTRICTED`` and ``READ_RESTRICTED``, equivalents of `Py_AUDIT_READ`. - In some configurations, ``<stddef.h>`` is not included from ``Python.h``. It should be included manually when using ``offsetof()``. The deprecated header continues to provide its original contents under the original names. Your old code can stay unchanged, unless the extra include and non-namespaced macros bother you greatly. There is discussion on the issue to rename `T_PYSSIZET` to `PY_T_SSIZE` or similar. I chose not to do that -- users will probably copy/paste that with any spelling, and not renaming it makes migration docs simpler. Co-Authored-By: Alexander Belopolsky <abalkin@users.noreply.github.com> Co-Authored-By: Matthias Braun <MatzeB@users.noreply.github.com>
* gh-93649: Split float/long tests from _testcapimodule.c (GH-99549)Erlend E. Aasland2022-11-171-623/+6
| | | Automerge-Triggered-By: GH:erlend-aasland
* gh-93649: Split watcher API tests from _testcapimodule.c (#99532)Erlend E. Aasland2022-11-161-285/+3
|
* gh-93649: Split memory and docstring tests from _testcapimodule.c (#99517)Erlend E. Aasland2022-11-161-670/+6
|
* gh-93649: Split pytime and datetime tests from _testcapimodule.c (#99494)Erlend E. Aasland2022-11-151-677/+6
|
* gh-93649: Split getargs tests from _testcapimodule.c (#99346)Erlend E. Aasland2022-11-141-831/+3
|
* gh-99300: Use Py_NewRef() in Modules/ directory (#99440)Victor Stinner2022-11-131-56/+28
| | | | Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and Py_XNewRef() in test C files of the Modules/ directory.
* gh-98724: Fix Py_CLEAR() macro side effects (#99100)Victor Stinner2022-11-091-0/+87
| | | | | | | The Py_CLEAR(), Py_SETREF() and Py_XSETREF() macros now only evaluate their argument once. If an argument has side effects, these side effects are no longer duplicated. Add test_py_clear() and test_py_setref() unit tests to _testcapi.
* gh-91248: Add PyFrame_GetVar() function (#95712)Victor Stinner2022-11-081-0/+34
| | | | | | Add PyFrame_GetVar() and PyFrame_GetVarString() functions to get a frame variable by its name. Move PyFrameObject C API tests from test_capi to test_frame.