]> granicus.if.org Git - python/commit
bpo-36389: _PyObject_CheckConsistency() available in release mode (GH-16612)
authorVictor Stinner <vstinner@python.org>
Mon, 7 Oct 2019 16:42:01 +0000 (18:42 +0200)
committerGitHub <noreply@github.com>
Mon, 7 Oct 2019 16:42:01 +0000 (18:42 +0200)
commit6876257eaabdb30f27ebcbd7d2557278ce2e5705
tree05597a0310d1e330c0c156c97f0fbc8a6386675e
parent321def805abc5b7c92c7e90ca90cb2434fdab855
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.
14 files changed:
Include/cpython/unicodeobject.h
Include/internal/pycore_object.h
Include/internal/pycore_pymem.h
Include/unicodeobject.h
Lib/test/test_capi.py
Lib/test/test_gc.py
Misc/NEWS.d/next/C API/2019-10-07-17-15-09.bpo-36389.hFX_jD.rst [new file with mode: 0644]
Modules/_testcapimodule.c
Modules/gcmodule.c
Objects/bytesobject.c
Objects/dictobject.c
Objects/object.c
Objects/typeobject.c
Objects/unicodeobject.c