summaryrefslogtreecommitdiffstats
path: root/Modules/_testcapimodule.c
Commit message (Collapse)AuthorAgeFilesLines
* [3.11] gh-107735: Add C API tests for PySys_GetObject() and ↵Serhiy Storchaka2023-08-071-0/+41
| | | | | PySys_SetObject() (GH-107736) (GH-107741) (cherry picked from commit bea5f93196d213d6fbf4ba8984caf4c3cd1da882)
* [3.11] gh-99612: Fix PyUnicode_DecodeUTF8Stateful() for ASCII-only data ↵Serhiy Storchaka2023-07-251-1/+36
| | | | | | | (GH-99613) (GH-107224) Previously *consumed was not set in this case. (cherry picked from commit f08e52ccb027f6f703302b8c1a82db9fd3934270)
* [3.11] GH-102818: Do not call PyTraceBack_Here in sys.settrace trampoline ↵Mark Shannon2023-05-191-0/+28
| | | | | (GH-104650) Backport of GH-104579
* [3.11] gh-104645: fix error handling in marshal tests (GH-104646) (#104663)Miss Islington (bot)2023-05-191-18/+14
| | | | | | gh-104645: fix error handling in marshal tests (GH-104646) (cherry picked from commit ac56a854b418d35ad3838f3072604227dc718fca) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
* [3.11] gh-102493: backport unit test for PyErr_SetObject (#102602)Irit Katriel2023-03-111-0/+15
| | | gh-102493: backport unit test for PyErr_SetObject
* [3.11] gh-101656: Fix "conversion from Py_ssize_t to int" warning in ↵Nikita Sobolev2023-02-081-3/+3
| | | | | `_testcapimodule` (#101680) (cherry picked from commit acc2f3b19d28d4bf3f8fb32357f581cba5ba24c7)
* [3.11] gh-101072: support default and kw default in PyEval_EvalCodeEx for ↵Łukasz Langa2023-02-071-0/+139
| | | | | | 3.11+ (GH-101127) (#101636) Co-authored-by: Łukasz Langa <lukasz@langa.pl> Co-authored-by: Matthieu Dartiailh <m.dartiailh@gmail.com>
* [3.11] GH-100892: Fix race in clearing `threading.local` (GH-100922). (#100937)Kumar Aditya2023-01-111-9/+39
| | | | | (cherry picked from commit 762745a124cbc297cf2fe6f3ec9ca1840bb2e873) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
* [3.11] gh-99110: Initialize frame->previous in init_frame to fix ↵Bill Fisher2022-12-241-0/+18
| | | | | | | segmentation fault (GH-100182) (#100478) (cherry picked from commit 88d565f32a709140664444c6dea20ecd35a10e94) Co-authored-by: Bill Fisher <william.w.fisher@gmail.com>
* [3.11] gh-99240: Reset pointer to NULL when the pointed memory is freed in ↵colorfulappl2022-12-211-0/+20
| | | | | | | | argument parsing (GH-99890) (#100385) (cherry picked from commit efbb1eb9f54cad4f7bf5df03eed3a6aba02d99f4) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* [3.11] Revert "[3.11] gh-98724: Fix Py_CLEAR() macro side effects (#99100)" ↵Victor Stinner2022-11-211-87/+0
| | | | | | | (#99573) Revert "gh-98724: Fix Py_CLEAR() macro side effects (#99100) (#99288)" This reverts commit 108289085719db8b227d65ce945e806f91be8f80.
* gh-98724: Fix Py_CLEAR() macro side effects (#99100) (#99288)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. (cherry picked from commit c03e05c2e72f3ea5e797389e7d1042eef85ad37a)
* gh-94808: add tests covering `PySequence_{Set,Del}Slice` (GH-99123)Miss Islington (bot)2022-11-051-0/+33
| | | | | (cherry picked from commit c5c40773cbadc8c35212877ea315a375f3bfaa4b) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* gh-94808: add tests covering `PyEval_GetFuncDesc` function (GH-98300)Miss Islington (bot)2022-11-051-0/+7
| | | | | (cherry picked from commit b5f711185bd11819566068ddf2a74a1402340e2d) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* gh-94808: cover `PyMapping_HasKeyString` and `PyMapping_HasKey` (GH-98486)Miss Islington (bot)2022-10-261-0/+36
| | | | | (cherry picked from commit 5d30544485dc56ab999ad7656ef6559306fd013f) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* [3.11] gh-94808: Cover `PyFunction_GetCode`, `PyFunction_GetGlobals`,… ↵Jelle Zijlstra2022-10-191-0/+40
| | | | | | | | | (#98317) [3.11] gh-94808: Cover `PyFunction_GetCode`, `PyFunction_GetGlobals`, `PyFunction_GetModule` (GH-98158). (cherry picked from commit 7b48d02933639c91ebd957b2326d8c352d8eddec) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* [3.11] gh-94808: Cover `PyEval_GetFuncName` (GH-98246). (#98283)Jelle Zijlstra2022-10-151-0/+7
| | | | | (cherry picked from commit f01b56c7bdec239abe0dae2706f8325f4336249c) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* gh-96821: Fix undefined behaviour in `_testcapimodule.c` (GH-96915) (GH-96927)Miss Islington (bot)2022-09-191-1/+3
| | | | | | | | | | * gh-96821: Assert for demonstrating undefined behaviour * Fix UB (cherry picked from commit cbdeda8ce7a3543cb3376d70e4cd46fcf24f42a7) Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM> Co-authored-by: Matthias Görgens <matthias.goergens@gmail.com>
* gh-95878: Fix format char in datetime CAPI tests (GH-95879) (#95885)Miss Islington (bot)2022-08-111-4/+4
| | | | | | | (cherry picked from commit 8b34e914bba2ccd6ae39609410db49d0beb19cb1) Co-authored-by: Christian Heimes <christian@python.org> Co-authored-by: Christian Heimes <christian@python.org>
* [3.11] gh-92678: Correct return values for errors in PyInit__testcapi (#95664)Pablo Galindo Salgado2022-08-041-2/+2
|
* gh-94936: C getters: co_varnames, co_cellvars, co_freevars (GH-95008)Miss Islington (bot)2022-08-041-11/+69
| | | | | (cherry picked from commit 42b102bbf9a9ae6fae8f6710202fb7afeeac277c) Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
* Revert "[3.11] GH-92678: Expose managed dict clear and visit functions ↵Mark Shannon2022-08-041-9/+0
| | | | | (GH-95246). (#95256)" (#95647) This reverts commit 7f731943393d57cf26ed5f2353e6e53084cd55fd.
* GH-92678: Fix tp_dictoffset inheritance. (GH-95596) (GH-95604)Mark Shannon2022-08-041-0/+28
| | | | | * 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.
* [3.11] GH-92678: Expose managed dict clear and visit functions (GH-95246). ↵Pablo Galindo Salgado2022-07-251-0/+9
| | | | | (#95256) Co-authored-by: Mark Shannon <mark@hotpy.org>
* GH-91153: Handle mutating __index__ methods in bytearray item assignment ↵Miss Islington (bot)2022-07-191-0/+16
| | | | | | | (GH-94891) (cherry picked from commit f36589510b8708fa224d799d5b328deab558aa4e) Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
* gh-94930: skipitem() in getargs.c should return non-NULL on error (GH-94931)Miss Islington (bot)2022-07-181-2/+21
| | | | | (cherry picked from commit 067f0da33506f70c36a67d5f3d8d011c8dae10c9) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-93937, C API: Move PyFrame_GetBack() to Python.h (#93938) (#94000)Victor Stinner2022-06-201-1/+0
| | | | | | | | | | | | | | | | | | Move the follow functions and type from frameobject.h to pyframe.h, so the standard <Python.h> provide frame getter functions: * PyFrame_Check() * PyFrame_GetBack() * PyFrame_GetBuiltins() * PyFrame_GetGenerator() * PyFrame_GetGlobals() * PyFrame_GetLasti() * PyFrame_GetLocals() * PyFrame_Type Remove #include "frameobject.h" from many C files. It's no longer needed. (cherry picked from commit 27b989403356ccdd47545a93aeab8434e9c69f21)
* Fix NULL check in test_type_from_ephemeral_spec in_testcapimodule.c (GH-92863)Miss Islington (bot)2022-05-171-1/+1
| | | | | (cherry picked from commit 524f03c08ca6688785c0fe99d8f2b385bf92e58f) Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
* GH-92236: Remove spurious "line" event when starting coroutine or generator. ↵Miss Islington (bot)2022-05-131-0/+46
| | | | | | (GH-92722) (GH-92772) (cherry picked from commit 22a1db378c5c381272362c5b2f68ac78a368e136)
* gh-91320: Use _PyCFunction_CAST() (#92251)Victor Stinner2022-05-031-20/+20
| | | | | | | | | | Replace "(PyCFunction)(void(*)(void))func" cast with _PyCFunction_CAST(func). Change generated by the command: sed -i -e \ 's!(PyCFunction)(void(\*)(void)) *\([A-Za-z0-9_]\+\)!_PyCFunction_CAST(\1)!g' \ $(find -name "*.c")
* gh-92154: Expose PyCode_GetCode in the C API (GH-92168)Ken Jin2022-05-031-0/+24
|
* gh-91324: List feature macros in the stable ABI manifest, improve tests ↵Petr Viktorin2022-04-281-0/+13
| | | | (GH-32415)
* gh-91731: Replace Py_BUILD_ASSERT() with static_assert() (#91730)Victor Stinner2022-04-201-1/+2
| | | | | | | | | | | | Python 3.11 now uses C11 standard which adds static_assert() to <assert.h>. * In pytime.c, replace Py_BUILD_ASSERT() with preprocessor checks on SIZEOF_TIME_T with #error. * On macOS, py_mach_timebase_info() now accepts timebase members with the same size than _PyTime_t. * py_get_monotonic_clock() now saturates GetTickCount64() to _PyTime_MAX: GetTickCount64() is unsigned, whereas _PyTime_t is signed.
* gh-91118: Fix docstrings that do not honor --without-doc-strings (#31769)Oleg Iarygin2022-04-181-1/+1
| | | | Co-authored-by: Éric <merwok@netwok.org> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* gh-90501: Add PyErr_GetHandledException and PyErr_SetHandledException (GH-30531)Irit Katriel2022-04-151-0/+11
|
* Add new PyFrame_GetLasti C-API function (GH-32413)Mark Shannon2022-04-081-0/+16
|
* bpo-40421: Add missing getters for frame object attributes to C-API. (GH-32114)Mark Shannon2022-03-311-0/+44
|
* bpo-46906: Add PyFloat_Pack8() to the C API (GH-31657)Victor Stinner2022-03-111-0/+81
| | | | | | | | | | | | | | | | | | | | | | Add new functions to pack and unpack C double (serialize and deserialize): * PyFloat_Pack2(), PyFloat_Pack4(), PyFloat_Pack8() * PyFloat_Unpack2(), PyFloat_Unpack4(), PyFloat_Unpack8() Document these functions and add unit tests. Rename private functions and move them from the internal C API to the public C API: * _PyFloat_Pack2() => PyFloat_Pack2() * _PyFloat_Pack4() => PyFloat_Pack4() * _PyFloat_Pack8() => PyFloat_Pack8() * _PyFloat_Unpack2() => PyFloat_Unpack2() * _PyFloat_Unpack4() => PyFloat_Unpack4() * _PyFloat_Unpack8() => PyFloat_Unpack8() Replace the "unsigned char*" type with "char*" which is more common and easy to use.
* bpo-46748: Don't import <stdbool.h> in public headers (GH-31553)Petr Viktorin2022-02-251-0/+3
| | | | | | | <stdbool.h> is the standard/modern way to define embedd/extends Python free to define bool, true and false, but there are existing applications that use slightly different redefinitions, which fail if the header is included. It's OK to use stdbool outside the public headers, though. https://bugs.python.org/issue46748
* bpo-46541: Replace core use of _Py_IDENTIFIER() with statically initialized ↵Eric Snow2022-02-081-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | global objects. (gh-30928) We're no longer using _Py_IDENTIFIER() (or _Py_static_string()) in any core CPython code. It is still used in a number of non-builtin stdlib modules. The replacement is: PyUnicodeObject (not pointer) fields under _PyRuntimeState, statically initialized as part of _PyRuntime. A new _Py_GET_GLOBAL_IDENTIFIER() macro facilitates lookup of the fields (along with _Py_GET_GLOBAL_STRING() for non-identifier strings). https://bugs.python.org/issue46541#msg411799 explains the rationale for this change. The core of the change is in: * (new) Include/internal/pycore_global_strings.h - the declarations for the global strings, along with the macros * Include/internal/pycore_runtime_init.h - added the static initializers for the global strings * Include/internal/pycore_global_objects.h - where the struct in pycore_global_strings.h is hooked into _PyRuntimeState * Tools/scripts/generate_global_objects.py - added generation of the global string declarations and static initializers I've also added a --check flag to generate_global_objects.py (along with make check-global-objects) to check for unused global strings. That check is added to the PR CI config. The remainder of this change updates the core code to use _Py_GET_GLOBAL_IDENTIFIER() instead of _Py_IDENTIFIER() and the related _Py*Id functions (likewise for _Py_GET_GLOBAL_STRING() instead of _Py_static_string()). This includes adding a few functions where there wasn't already an alternative to _Py*Id(), replacing the _Py_Identifier * parameter with PyObject *. The following are not changed (yet): * stop using _Py_IDENTIFIER() in the stdlib modules * (maybe) get rid of _Py_IDENTIFIER(), etc. entirely -- this may not be doable as at least one package on PyPI using this (private) API * (maybe) intern the strings during runtime init https://bugs.python.org/issue46541
* bpo-46670: Remove unused macros in the Modules directory (GH-31194)Victor Stinner2022-02-071-2/+0
| | | | | * bpo-46670: Remove unused macros in the Modules directory * Add again LINKAT_DIR_FD_CONVERTER: generated by Argument Clinic
* bpo-40280: Allow to compile _testcapi as builtin module (GH-30559)Christian Heimes2022-01-121-0/+2
|
* bpo-46303: Move fileutils.h private functions to internal C API (GH-30484)Victor Stinner2022-01-111-94/+0
| | | | | | | | | | Move almost all private functions of Include/cpython/fileutils.h to the internal C API Include/internal/pycore_fileutils.h. Only keep _Py_fopen_obj() in Include/cpython/fileutils.h, since it's used by _testcapi which must not use the internal C API. Move EncodeLocaleEx() and DecodeLocaleEx() functions from _testcapi to _testinternalcapi, since the C API moved to the internal C API.
* bpo-45615: Add missing test for printing traceback for non-exception. Fix ↵Irit Katriel2022-01-021-6/+6
| | | | traceback.py (GH-30091)
* bpo-43931: Export Python version as API data (GH-25577)Gabriele N. Tornetta2021-12-101-0/+1
| | | | | 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
* bpo-45947: Place dict and values pointer at fixed (negative) offset just ↵Mark Shannon2021-12-071-5/+12
| | | | | | | | | | | | | | | | | | | before GC header. (GH-29879) * Place __dict__ immediately before GC header for plain Python objects. * Fix up lazy dict creation logic to use managed dict pointers. * Manage values pointer, placing them directly before managed dict pointers. * Convert hint-based load/store attr specialization target managed dict classes. * Specialize LOAD_METHOD for managed dict objects. * Remove unsafe _PyObject_GC_Calloc function. * Remove unsafe _PyObject_GC_Malloc() function. * Add comment explaning use of Py_TPFLAGS_MANAGED_DICT.
* bpo-45822: Minor cleanups to the test_Py_CompileString test (GH-29750)Pablo Galindo Salgado2021-11-241-1/+1
|
* bpo-45822: Respect PEP 263's coding cookies in the parser even if flags are ↵Pablo Galindo Salgado2021-11-161-0/+14
| | | | not provided (GH-29582)
* bpo-45315: PyType_FromSpec: Copy spec->name and have the type own the memory ↵Petr Viktorin2021-10-211-0/+121
| | | | for its name (GH-29103)
* bpo-43760: Add PyThreadState_EnterTracing() (GH-28542)Victor Stinner2021-10-151-6/+61
| | | | | | | | | | Add PyThreadState_EnterTracing() and PyThreadState_LeaveTracing() functions to the limited C API to suspend and resume tracing and profiling. Add an unit test on the PyThreadState C API to _testcapi. Add also internal _PyThreadState_DisableTracing() and _PyThreadState_ResetTracing().