mirror of
https://github.com/python/cpython.git
synced 2025-07-23 03:05:38 +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
|
@ -131,8 +131,7 @@ skip_signature(const char *doc)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
static int
|
||||
int
|
||||
_PyType_CheckConsistency(PyTypeObject *type)
|
||||
{
|
||||
#define ASSERT(expr) _PyObject_ASSERT((PyObject *)type, (expr))
|
||||
|
@ -142,14 +141,16 @@ _PyType_CheckConsistency(PyTypeObject *type)
|
|||
return 1;
|
||||
}
|
||||
|
||||
ASSERT(!(type->tp_flags & Py_TPFLAGS_READYING));
|
||||
ASSERT(type->tp_mro != NULL && PyTuple_Check(type->tp_mro));
|
||||
ASSERT(type->tp_dict != NULL);
|
||||
return 1;
|
||||
ASSERT(!_PyObject_IsFreed((PyObject *)type));
|
||||
ASSERT(Py_REFCNT(type) >= 1);
|
||||
ASSERT(PyType_Check(type));
|
||||
|
||||
ASSERT(!(type->tp_flags & Py_TPFLAGS_READYING));
|
||||
ASSERT(type->tp_dict != NULL);
|
||||
|
||||
return 1;
|
||||
#undef ASSERT
|
||||
}
|
||||
#endif
|
||||
|
||||
static const char *
|
||||
_PyType_DocWithoutSignature(const char *name, const char *internal_doc)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue