summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_capi.py
Commit message (Collapse)AuthorAgeFilesLines
* bpo-34272: Reorganize C API tests. (GH-8551)Serhiy Storchaka2022-11-101-2037/+0
| | | | Move some C API tests into Lib/test/test_capi/.
* gh-91248: Add PyFrame_GetVar() function (#95712)Victor Stinner2022-11-081-21/+0
| | | | | | 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.
* gh-94808: add tests covering `PyFunction_GetKwDefaults` and ↵Nikita Sobolev2022-11-051-3/+95
| | | | `PyFunction_SetKwDefaults` (GH-98809)
* gh-94808: add tests covering `PySequence_{Set,Del}Slice` (GH-99123)Nikita Sobolev2022-11-051-0/+80
|
* gh-94808: add tests covering `PyEval_GetFuncDesc` function (GH-98300)Nikita Sobolev2022-11-051-0/+15
|
* gh-98610: Adjust the Optional Restrictions on Subinterpreters (GH-98618)Eric Snow2022-10-311-5/+6
| | | | | | | Previously, the optional restrictions on subinterpreters were: disallow fork, subprocess, and threads. By default, we were disallowing all three for "isolated" interpreters. We always allowed all three for the main interpreter and those created through the legacy `Py_NewInterpreter()` API. Those settings were a bit conservative, so here we've adjusted the optional restrictions to: fork, exec, threads, and daemon threads. The default for "isolated" interpreters disables fork, exec, and daemon threads. Regular threads are allowed by default. We continue always allowing everything For the main interpreter and the legacy API. In the code, we add `_PyInterpreterConfig.allow_exec` and `_PyInterpreterConfig.allow_daemon_threads`. We also add `Py_RTFLAGS_DAEMON_THREADS` and `Py_RTFLAGS_EXEC`.
* gh-94808: cover `PyFunction_GetDefaults` and `PyFunction_SetDefaults` (#98449)Nikita Sobolev2022-10-271-0/+42
|
* gh-98608: Change _Py_NewInterpreter() to _Py_NewInterpreterFromConfig() ↵Eric Snow2022-10-261-0/+39
| | | | | | | | | | | | | | | | | | | | | | | | | (gh-98609) (see https://github.com/python/cpython/issues/98608) This change does the following: 1. change the argument to a new `_PyInterpreterConfig` struct 2. rename the function to `_Py_NewInterpreterFromConfig()`, inspired by `Py_InitializeFromConfig()` (takes a `_PyInterpreterConfig` instead of `isolated_subinterpreter`) 3. split up the boolean `isolated_subinterpreter` into the corresponding multiple granular settings * allow_fork * allow_subprocess * allow_threads 4. add `PyInterpreterState.feature_flags` to store those settings 5. add a function for checking if a feature is enabled on an opaque `PyInterpreterState *` 6. drop `PyConfig._isolated_interpreter` The existing default (see `Py_NewInterpeter()` and `Py_Initialize*()`) allows fork, subprocess, and threads and the optional "isolated" interpreter (see the `_xxsubinterpreters` module) disables all three. None of that changes here; the defaults are preserved. Note that the given `_PyInterpreterConfig` will not be used outside `_Py_NewInterpreterFromConfig()`, nor preserved. This contrasts with how `PyConfig` is currently preserved, used, and even modified outside `Py_InitializeFromConfig()`. I'd rather just avoid that mess from the start for `_PyInterpreterConfig`. We can preserve it later if we find an actual need. This change allows us to follow up with a number of improvements (e.g. stop disallowing subprocess and support disallowing exec instead). (Note that this PR adds "private" symbols. We'll probably make them public, and add docs, in a separate change.)
* gh-94808: cover `PyMapping_HasKeyString` and `PyMapping_HasKey` (#98486)Nikita Sobolev2022-10-261-0/+12
|
* gh-91051: allow setting a callback hook on PyType_Modified (GH-97875)Carl Meyer2022-10-211-1/+168
|
* gh-94808: Cover `PyFunction_GetCode`, `PyFunction_GetGlobals`, ↵Nikita Sobolev2022-10-161-0/+35
| | | | `PyFunction_GetModule` (#98158)
* gh-94808: Cover `PyEval_GetFuncName` (#98246)Nikita Sobolev2022-10-151-0/+15
|
* gh-91052: Add PyDict_Unwatch for unwatching a dictionary (#98055)Carl Meyer2022-10-081-16/+44
|
* Fix memory leaks in test_capi (#98017)Carl Meyer2022-10-071-0/+3
|
* GH-91052: Add C API for watching dictionaries (GH-31787)Carl Meyer2022-10-071-0/+132
|
* gh-96512: Move int_max_str_digits setting to PyConfig (#96944)Gregory P. Smith2022-10-031-0/+33
| | | | | | | | | | | It had to live as a global outside of PyConfig for stable ABI reasons in the pre-3.12 backports. This removes the `_Py_global_config_int_max_str_digits` and gets rid of the equivalent field in the internal `struct _is PyInterpreterState` as code can just use the existing nested config struct within that. Adds tests to verify unique settings and configs in subinterpreters.
* gh-93884: Improve test coverage of `PyNumber_ToBase` (GH-93932)Charlie Zhao2022-09-041-8/+24
| | | | | | | Link to #93884 * Test with some large negative and positive values(out of range of a longlong,i.e.[-2\*\*63, 2\*\*63-1]) * Test with objects of non-int type Automerge-Triggered-By: GH:mdickinson
* GH-96071: add regression test for #96071 (GH-96137)Kumar Aditya2022-08-221-0/+15
| | | Automerge-Triggered-By: GH:ericsnowcurrently
* GH-95589: Dont crash when subclassing extension classes with multiple ↵Mark Shannon2022-08-171-11/+33
| | | | | | | inheritance (GH-96028) * Treat tp_weakref and tp_dictoffset like other opaque slots for multiple inheritance. * Document Py_TPFLAGS_MANAGED_DICT and Py_TPFLAGS_MANAGED_WEAKREF in what's new.
* GH-95245: Move weakreflist into the pre-header. (GH-95996)Mark Shannon2022-08-161-0/+31
|
* GH-95707: Fix uses of `Py_TPFLAGS_MANAGED_DICT` (GH-95854)Mark Shannon2022-08-151-0/+24
| | | | | | * Make sure that tp_dictoffset is correct with Py_TPFLAGS_MANAGED_DICT is set. * Avoid traversing managed dict twice when subclassing class with Py_TPFLAGS_MANAGED_DICT set.
* gh-95388: Suppress deprecation warning in ↵Erlend E. Aasland2022-08-081-0/+1
| | | | | | test_immutable_type_with_mutable_base (GH-95728) When 3.14 kicks in, it'll be a RuntimeError; the test will correctly fail then.
* gh-95388: Deprecate creating immutable types with mutable bases (GH-95533)Petr Viktorin2022-08-041-0/+29
|
* GH-92678: Fix tp_dictoffset inheritance. (GH-95596)Mark Shannon2022-08-031-0/+19
| | | | | | * Add test for inheriting explicit __dict__ and weakref. * Restore 3.10 behavior for multiple inheritance of C extension classes that store their dictionary at the end of the struct.
* GH-92678: Expose managed dict clear and visit functions (#95246)Mark Shannon2022-07-251-0/+14
|
* gh-77782: Py_FdIsInteractive() now uses PyConfig.interactive (#93916)Victor Stinner2022-06-171-8/+9
|
* gh-93466: Document PyType_Spec doesn't accept repeated slot IDs; raise where ↵Petr Viktorin2022-06-101-0/+6
| | | | this was problematic (GH-93471)
* gh-60074: add new stable API function PyType_FromMetaclass (GH-93012)Wenzel Jakob2022-05-271-0/+13
| | | | | | | | Added a new stable API function ``PyType_FromMetaclass``, which mirrors the behavior of ``PyType_FromModuleAndSpec`` except that it takes an additional metaclass argument. This is, e.g., useful for language binding tools that need to store additional information in the type object.
* gh-69443: Add test.support.Py_DEBUG constant (#93226)Victor Stinner2022-05-251-8/+5
|
* gh-90473: WASI: Mark tests that require os.pipe() (GH-92837)Christian Heimes2022-05-161-0/+2
|
* gh-82616: Add process_group support to subprocess.Popen (#23930)Gregory P. Smith2022-05-051-3/+3
| | | | | | | | One more thing that can help prevent people from using `preexec_fn`. Also adds conditional skips to two tests exposing ASAN flakiness on the Ubuntu 20.04 Address Sanitizer Github CI system. When that build is run on more modern systems the "problem" does not show up. It seems ASAN implementation related. Co-authored-by: Zackery Spytz <zspytz@gmail.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* GH-92239: Make sure that PEP 523 is supported, even when specializing first. ↵Mark Shannon2022-05-041-0/+28
| | | | (GH-92245)
* gh-91401: Add a failsafe way to disable vfork. (#91490)Gregory P. Smith2022-04-251-3/+3
| | | | | | | | | | | | | | Just in case there is ever an issue with _posixsubprocess's use of vfork() due to the complexity of using it properly and potential directions that Linux platforms where it defaults to on could take, this adds a failsafe so that users can disable its use entirely by setting a global flag. No known reason to disable it exists. But it'd be a shame to encounter one and not be able to use CPython without patching and rebuilding it. See the linked issue for some discussion on reasoning. Also documents the existing way to disable posix_spawn.
* gh-89373: _Py_Dealloc() checks tp_dealloc exception (#32357)Victor Stinner2022-04-211-2/+12
| | | | If Python is built in debug mode, _Py_Dealloc() now ensures that the tp_dealloc function leaves the current exception unchanged.
* gh-90501: Add PyErr_GetHandledException and PyErr_SetHandledException (GH-30531)Irit Katriel2022-04-151-0/+22
|
* Add new PyFrame_GetLasti C-API function (GH-32413)Mark Shannon2022-04-081-0/+1
|
* bpo-40280: Detect missing threading on WASM platforms (GH-32352)Christian Heimes2022-04-071-0/+2
| | | Co-authored-by: Brett Cannon <brett@python.org>
* bpo-40421: test_capi uses assertEqual(), not assertEquals() (GH-32361)Victor Stinner2022-04-061-1/+1
| | | | | | | unittest.TestCase.assertEquals() alias is depracated. Fix the warning: Lib/test/test_capi.py:1100: DeprecationWarning: Please use assertEqual instead. self.assertEquals(frame.f_locals, _testcapi.frame_getlocals(frame))
* bpo-40421: Add missing getters for frame object attributes to C-API. (GH-32114)Mark Shannon2022-03-311-0/+20
|
* bpo-46841: Use inline cache for `BINARY_SUBSCR`. (GH-31618)Mark Shannon2022-03-011-1/+1
|
* bpo-46613: Add PyType_GetModuleByDef to the public API (GH-31081)Petr Viktorin2022-02-111-2/+2
| | | | | * Make PyType_GetModuleByDef public (remove underscore) Co-authored-by: Victor Stinner <vstinner@python.org>
* bpo-40280: Address more test failures on Emscripten (GH-31050)Christian Heimes2022-02-051-0/+2
| | | Co-authored-by: Brett Cannon <brett@python.org>
* bpo-46433: _PyType_GetModuleByDef: handle static types in MRO (GH-30696)Petr Viktorin2022-02-021-0/+16
| | | Automerge-Triggered-By: GH:encukou
* bpo-40280: Skip subprocess-based tests on wasm32-emscripten (GH-30615)Christian Heimes2022-01-251-0/+1
|
* bpo-40280: Misc fixes for wasm32-emscripten (GH-30722)Christian Heimes2022-01-201-0/+6
|
* bpo-44133: Skip PyThread_get_thread_native_id() if not available (GH-30636)Victor Stinner2022-01-171-1/+7
| | | | | | test_capi.test_export_symbols() doesn't check if Python exports the "PyThread_get_thread_native_id" symbol if the _thread.get_native_id() function is not available (if the PY_HAVE_THREAD_NATIVE_ID macro is not defined).
* bpo-44133: Link Python executable with object files (GH-30556)Victor Stinner2022-01-131-0/+18
| | | | | | | | | | | | | | When Python is built without --enable-shared, the "python" program is now linked to object files, rather than being linked to the Python library (libpython.a), to make sure that all symbols are exported. Previously, the linker omitted some symbols like the Py_FrozenMain() function. When Python is configured with --without-static-libpython, the Python static library (libpython.a) is no longer built. * Check --without-static-libpython earlier in configure.ac * Add LINK_PYTHON_OBJS and LINK_PYTHON_DEPS variables to Makefile. * test_capi now ensures that the "Py_FrozenMain" symbol is exported.
* bpo-46263: Fix second location that needs MALLOC_CONF on FreeBSD (GH-30440)Christian Heimes2022-01-061-1/+5
| | | Automerge-Triggered-By: GH:tiran
* bpo-46263: FreeBSD 14.0 jemalloc workaround for junk bytes of freed memory ↵Christian Heimes2022-01-061-2/+7
| | | | | (GH-30434) Automerge-Triggered-By: GH:tiran
* bpo-43931: Export Python version as API data (GH-25577)Gabriele N. Tornetta2021-12-101-0/+3
| | | | | When Python is embedded in other applications, it is not easy to determine which version of Python is being used. This change exposes the Python version as part of the API data. Tools like Austin (https://github.com/P403n1x87/austin) can benefit from this data when targeting applications like uWSGI, as the Python version can then be inferred systematically by looking at the exported symbols rather than relying on unreliable pattern matching or other hacks (like remote code execution etc...). Automerge-Triggered-By: GH:pablogsal