summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_capi/test_misc.py
Commit message (Collapse)AuthorAgeFilesLines
* [3.12] gh-109496: Detect Py_DECREF() after dealloc in debug mode (GH-109539) ↵Miss Islington (bot)2023-09-181-10/+26
| | | | | | | | | | | | | | | | | (#109545) gh-109496: Detect Py_DECREF() after dealloc in debug mode (GH-109539) On a Python built in debug mode, Py_DECREF() now calls _Py_NegativeRefcount() if the object is a dangling pointer to deallocated memory: memory filled with 0xDD "dead byte" by the debug hook on memory allocators. The fix is to check the reference count *before* checking for _Py_IsImmortal(). Add test_decref_freed_object() to test_capi.test_misc. (cherry picked from commit 0bb0d88e2d4e300946e399e088e2ff60de2ccf8c) Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.12] gh-107178: Add the C API tests for the Abstract Objects Layer ↵Serhiy Storchaka2023-08-161-131/+0
| | | | | | | | | | | | (GH-107179) (#107728) Cover all the Mapping Protocol, almost all the Sequence Protocol (except PySequence_Fast) and a part of the Object Protocol. Move existing tests to Lib/test/test_capi/test_abstract.py and Modules/_testcapi/abstract.c. Add also tests for PyDict C API.. (cherry picked from commit 16c9415fba4972743f1944ebc44946e475e68bc4)
* [3.12] gh-107735: Add C API tests for PySys_GetObject() and ↵Serhiy Storchaka2023-08-161-0/+42
| | | | | | PySys_SetObject() (GH-107736) (#107740) [3.12] gh-107735: Add C API tests for PySys_GetObject() and PySys_SetObject() (GH-107736). (cherry picked from commit bea5f93196d213d6fbf4ba8984caf4c3cd1da882)
* [3.12] gh-107810: Improve DeprecationWarning for metaclasses with custom ↵Miss Islington (bot)2023-08-111-1/+1
| | | | | | | | | | tp_new (GH-107834) (#107864) gh-107810: Improve DeprecationWarning for metaclasses with custom tp_new (GH-107834) (cherry picked from commit 16dcce21768ba381996a88ac8c255bf1490b3680) Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
* [3.12] gh-106714: Fix test_capi to not write a coredump (GH-107007) (#107009)Miss Islington (bot)2023-07-221-3/+9
| | | | | | | | | gh-106714: Fix test_capi to not write a coredump (GH-107007) test_capi: Fix test_no_FatalError_infinite_loop() to no longer write a coredump, by using test.support.SuppressCrashReport. (cherry picked from commit 4a1026d7647c084b0dc80dd49163d16ba12a2e55) Co-authored-by: Victor Stinner <vstinner@python.org>
* [3.12] gh-104812: Run Pending Calls in any Thread (gh-104813) (gh-105752)Eric Snow2023-06-141-1/+402
| | | | For a while now, pending calls only run in the main thread (in the main interpreter). This PR changes things to allow any thread run a pending call, unless the pending call was explicitly added for the main thread to run. (cherry picked from commit 757b402)
* [3.12] gh-103968: PyType_FromMetaclass: Allow metaclasses with tp_new=NULL ↵Miss Islington (bot)2023-06-121-7/+36
| | | | | | | | (GH-105386) (GH-105697) gh-103968: PyType_FromMetaclass: Allow metaclasses with tp_new=NULL (GH-105386) (cherry picked from commit 2b90796be6959d5ef46b38c434a514fce25be971) Co-authored-by: Petr Viktorin <encukou@gmail.com>
* [3.12] gh-104614: Make Sure ob_type is Always Set Correctly by ↵Miss Islington (bot)2023-06-011-1/+37
| | | | | | | | | | PyType_Ready() (gh-105122) (gh-105211) 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. (cherry picked from commit 1469393) Co-authored-by: Eric Snow ericsnowcurrently@gmail.com
* [3.12] gh-105020: Share tp_bases and tp_mro Between Interpreters For All ↵Miss Islington (bot)2023-06-011-0/+33
| | | | | | | | Static Builtin Types (gh-105115) (gh-105124) 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. (cherry picked from commit 7be667d) Co-authored-by: Eric Snow ericsnowcurrently@gmail.com
* GH-96803: Document and test new unstable internal frame API functions ↵Mark Shannon2023-05-181-0/+24
| | | | | | (GH-104211) Weaken contract of PyUnstable_InterpreterFrame_GetCode to return PyObject*.
* GH-104405: Add missing PEP 523 checks (GH-104406)Brandt Bucher2023-05-121-18/+70
|
* gh-99113: Add PyInterpreterConfig.own_gil (gh-104204)Eric Snow2023-05-051-10/+26
| | | | | 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-103509: PEP 697 -- Limited C API for Extending Opaque Types (GH-103511)Petr Viktorin2023-05-041-1/+157
| | | | Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* gh-103968: Deprecate creating heap types whose metaclass has custom tp_new. ↵Petr Viktorin2023-05-031-0/+14
| | | | | | | | (GH-103972) (That's a mouthful of an edge case!) Co-authored-by: Barney Gale <barney.gale@gmail.com>
* gh-103743: Add PyUnstable_Object_GC_NewWithExtraData (GH-103744)Jurica Bradarić2023-05-021-0/+14
| | | | Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* GH-103805: Lib test f541 linting issue fix (#103812)Rodolfo M. Pereira2023-04-241-1/+1
| | | | | | | | | | | | | | | | This PR makes some minor linting adjustments to the Lib/test module caught by [ruff](https://github.com/charliermarsh/ruff). The adjustments are all related to the `F541 f-string without any placeholders` issue. Issue: https://github.com/python/cpython/issues/103805 <!-- gh-issue-number: gh-103805 --> * Issue: gh-103805 <!-- /gh-issue-number --> --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Gregory P. Smith <greg@krypto.org>
* gh-101659: Isolate "obmalloc" State to Each Interpreter (gh-101660)Eric Snow2023-04-241-6/+27
| | | | | | | | | | | | | | 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-68586: use run_python_until_end in test_capi (GH-102729)Furkan Onder2023-04-091-11/+7
| | | | | Co-authored-by: Aidin Gharibnavaz Automerge-Triggered-By: GH:kumaraditya303
* gh-93649: Split exception tests from _testcapimodule.c (GH-102173)Erlend E. Aasland2023-02-231-128/+3
| | | Automerge-Triggered-By: GH:erlend-aasland
* GH-100719: Remove redundant `gi_code` field from generator object. (GH-100749)Mark Shannon2023-02-231-0/+5
|
* GH-84783: Make the slice object hashable (GH-101264)Furkan Onder2023-02-191-6/+1
|
* gh-98627: Add an Optional Check for Extension Module Subinterpreter ↵Eric Snow2023-02-161-5/+93
| | | | | | | | | | | | | | | 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-101578: Normalize the current exception (GH-101607)Mark Shannon2023-02-081-0/+39
| | | | | | | | | | * 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-59956: Add a Test to Verify GILState Matches the "Current" Thread State ↵Eric Snow2023-02-061-0/+3
| | | | | | | (gh-101625) This test should have been in gh-101431. https://github.com/python/cpython/issues/59956
* gh-93649: Split tracemalloc tests from _testcapimodule.c (#99551)Erlend E. Aasland2022-12-171-154/+0
|
* gh-60203: Always pass True/False as boolean arguments in tests (GH-99983)Serhiy Storchaka2022-12-041-4/+5
| | | Unless we explicitly test non-bool values.
* gh-93649: Split watcher API tests from _testcapimodule.c (#99532)Erlend E. Aasland2022-11-161-330/+0
|
* bpo-34272: Reorganize C API tests. (GH-8551)Serhiy Storchaka2022-11-101-0/+2037
Move some C API tests into Lib/test/test_capi/.