mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
bpo-46417: Add _PyType_CAST() macro (GH-30760)
In debug mode, the macro makes sure that its argument is a type using an assertion.
This commit is contained in:
parent
60705cff70
commit
bc67f189fd
3 changed files with 50 additions and 58 deletions
|
@ -755,6 +755,8 @@ static inline int _PyType_Check(PyObject *op) {
|
|||
}
|
||||
#define PyType_Check(op) _PyType_Check(_PyObject_CAST(op))
|
||||
|
||||
#define _PyType_CAST(op) (assert(PyType_Check(op)), (PyTypeObject*)(op))
|
||||
|
||||
static inline int _PyType_CheckExact(PyObject *op) {
|
||||
return Py_IS_TYPE(op, &PyType_Type);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue