diff options
author | Victor Stinner <vstinner@python.org> | 2019-10-07 16:42:01 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-07 16:42:01 (GMT) |
commit | 6876257eaabdb30f27ebcbd7d2557278ce2e5705 (patch) | |
tree | 05597a0310d1e330c0c156c97f0fbc8a6386675e /Lib/test | |
parent | 321def805abc5b7c92c7e90ca90cb2434fdab855 (diff) | |
download | cpython-6876257eaabdb30f27ebcbd7d2557278ce2e5705.zip cpython-6876257eaabdb30f27ebcbd7d2557278ce2e5705.tar.gz cpython-6876257eaabdb30f27ebcbd7d2557278ce2e5705.tar.bz2 |
bpo-36389: _PyObject_CheckConsistency() available in release mode (GH-16612)
bpo-36389, bpo-38376: The _PyObject_CheckConsistency() function is
now also available in release mode. For example, it can be used to
debug a crash in the visit_decref() function of the GC.
Modify the following functions to also work in release mode:
* _PyDict_CheckConsistency()
* _PyObject_CheckConsistency()
* _PyType_CheckConsistency()
* _PyUnicode_CheckConsistency()
Other changes:
* _PyMem_IsPtrFreed(ptr) now also returns 1 if ptr is NULL
(equals to 0).
* _PyBytesWriter_CheckConsistency() now returns 1 and is only used
with assert().
* Reorder _PyObject_Dump() to write safe fields first, and only
attempt to render repr() at the end.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_capi.py | 3 | ||||
-rw-r--r-- | Lib/test/test_gc.py | 15 |
2 files changed, 12 insertions, 6 deletions
diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py index 79059bc..6731447 100644 --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -719,6 +719,9 @@ class PyMemDebugTests(unittest.TestCase): ''') assert_python_ok('-c', code, PYTHONMALLOC=self.PYTHONMALLOC) + def test_pyobject_null_is_freed(self): + self.check_pyobject_is_freed('check_pyobject_null_is_freed') + def test_pyobject_uninitialized_is_freed(self): self.check_pyobject_is_freed('check_pyobject_uninitialized_is_freed') diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py index 311143d..8215390 100644 --- a/Lib/test/test_gc.py +++ b/Lib/test/test_gc.py @@ -985,16 +985,19 @@ class GCCallbackTests(unittest.TestCase): br'gcmodule\.c:[0-9]+: gc_decref: Assertion "gc_get_refs\(g\) > 0" failed.') self.assertRegex(stderr, br'refcount is too small') + # "address : 0x7fb5062efc18" + # "address : 7FB5062EFC18" + address_regex = br'[0-9a-fA-Fx]+' self.assertRegex(stderr, - br'object : \[1, 2, 3\]') + br'object address : ' + address_regex) self.assertRegex(stderr, - br'type : list') + br'object refcount : 1') self.assertRegex(stderr, - br'refcount: 1') - # "address : 0x7fb5062efc18" - # "address : 7FB5062EFC18" + br'object type : ' + address_regex) + self.assertRegex(stderr, + br'object type name: list') self.assertRegex(stderr, - br'address : [0-9a-fA-Fx]+') + br'object repr : \[1, 2, 3\]') class GCTogglingTests(unittest.TestCase): |