mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-106320: Remove private _PyObject C API (#107147)
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.
This commit is contained in:
parent
0810b0c435
commit
0d6dfd68d2
12 changed files with 116 additions and 112 deletions
|
@ -8,8 +8,10 @@ from test.support import import_helper, requires_subprocess
|
|||
from test.support.script_helper import assert_python_failure, assert_python_ok
|
||||
|
||||
|
||||
# Skip this test if the _testcapi module isn't available.
|
||||
# Skip this test if the _testcapi and _testinternalcapi extensions are not
|
||||
# available.
|
||||
_testcapi = import_helper.import_module('_testcapi')
|
||||
_testinternalcapi = import_helper.import_module('_testinternalcapi')
|
||||
|
||||
@requires_subprocess()
|
||||
class PyMemDebugTests(unittest.TestCase):
|
||||
|
@ -84,16 +86,13 @@ class PyMemDebugTests(unittest.TestCase):
|
|||
|
||||
def check_pyobject_is_freed(self, func_name):
|
||||
code = textwrap.dedent(f'''
|
||||
import gc, os, sys, _testcapi
|
||||
import gc, os, sys, _testinternalcapi
|
||||
# Disable the GC to avoid crash on GC collection
|
||||
gc.disable()
|
||||
try:
|
||||
_testcapi.{func_name}()
|
||||
# Exit immediately to avoid a crash while deallocating
|
||||
# the invalid object
|
||||
os._exit(0)
|
||||
except _testcapi.error:
|
||||
os._exit(1)
|
||||
_testinternalcapi.{func_name}()
|
||||
# Exit immediately to avoid a crash while deallocating
|
||||
# the invalid object
|
||||
os._exit(0)
|
||||
''')
|
||||
assert_python_ok(
|
||||
'-c', code,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue