mirror of
https://github.com/python/cpython.git
synced 2025-11-01 10:45:30 +00:00
bpo-36389: Add _PyObject_CheckConsistency() function (GH-12803)
Add a new _PyObject_CheckConsistency() function which can be used to help debugging. The function is available in release mode. Add a 'check_content' parameter to _PyDict_CheckConsistency().
This commit is contained in:
parent
23a683adf8
commit
0fc91eef34
6 changed files with 160 additions and 116 deletions
|
|
@ -446,6 +446,21 @@ PyAPI_FUNC(void) _PyObject_AssertFailed(
|
|||
int line,
|
||||
const char *function);
|
||||
|
||||
/* Check if an object is consistent. For example, ensure that the reference
|
||||
counter is greater than or equal to 1, and ensure that ob_type is not NULL.
|
||||
|
||||
Call _PyObject_AssertFailed() if the object is inconsistent.
|
||||
|
||||
If check_content is zero, only check header fields: reduce the overhead.
|
||||
|
||||
The function always return 1. The return value is just here to be able to
|
||||
write:
|
||||
|
||||
assert(_PyObject_CheckConsistency(obj, 1)); */
|
||||
PyAPI_FUNC(int) _PyObject_CheckConsistency(
|
||||
PyObject *op,
|
||||
int check_content);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -10,6 +10,10 @@ extern "C" {
|
|||
|
||||
#include "pycore_pystate.h" /* _PyRuntime */
|
||||
|
||||
PyAPI_FUNC(int) _PyType_CheckConsistency(PyTypeObject *type);
|
||||
PyAPI_FUNC(int) _PyUnicode_CheckConsistency(PyObject *op, int check_content);
|
||||
PyAPI_FUNC(int) _PyDict_CheckConsistency(PyObject *mp, int check_content);
|
||||
|
||||
/* Tell the GC to track this object.
|
||||
*
|
||||
* NB: While the object is tracked by the collector, it must be safe to call the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue