mirror of https://github.com/python/cpython
bpo-39573: Clean up modules and headers to use Py_IS_TYPE() function (GH-18521)
This commit is contained in:
parent
a7847590f0
commit
1b55b65638
|
@ -51,7 +51,7 @@ typedef struct _frame {
|
||||||
|
|
||||||
PyAPI_DATA(PyTypeObject) PyFrame_Type;
|
PyAPI_DATA(PyTypeObject) PyFrame_Type;
|
||||||
|
|
||||||
#define PyFrame_Check(op) (Py_TYPE(op) == &PyFrame_Type)
|
#define PyFrame_Check(op) Py_IS_TYPE(op, &PyFrame_Type)
|
||||||
|
|
||||||
PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *,
|
PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *,
|
||||||
PyObject *, PyObject *);
|
PyObject *, PyObject *);
|
||||||
|
|
|
@ -13,7 +13,7 @@ PyAPI_DATA(PyTypeObject) PyLong_Type;
|
||||||
|
|
||||||
#define PyLong_Check(op) \
|
#define PyLong_Check(op) \
|
||||||
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS)
|
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS)
|
||||||
#define PyLong_CheckExact(op) (Py_TYPE(op) == &PyLong_Type)
|
#define PyLong_CheckExact(op) Py_IS_TYPE(op, &PyLong_Type)
|
||||||
|
|
||||||
PyAPI_FUNC(PyObject *) PyLong_FromLong(long);
|
PyAPI_FUNC(PyObject *) PyLong_FromLong(long);
|
||||||
PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLong(unsigned long);
|
PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLong(unsigned long);
|
||||||
|
|
|
@ -82,7 +82,7 @@ _get_impl(PyObject *self)
|
||||||
if (impl == NULL) {
|
if (impl == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (Py_TYPE(impl) != &_abc_data_type) {
|
if (!Py_IS_TYPE(impl, &_abc_data_type)) {
|
||||||
PyErr_SetString(PyExc_TypeError, "_abc_impl is set to a wrong type");
|
PyErr_SetString(PyExc_TypeError, "_abc_impl is set to a wrong type");
|
||||||
Py_DECREF(impl);
|
Py_DECREF(impl);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -112,8 +112,8 @@ static PyTypeObject TaskType;
|
||||||
static PyTypeObject PyRunningLoopHolder_Type;
|
static PyTypeObject PyRunningLoopHolder_Type;
|
||||||
|
|
||||||
|
|
||||||
#define Future_CheckExact(obj) (Py_TYPE(obj) == &FutureType)
|
#define Future_CheckExact(obj) Py_IS_TYPE(obj, &FutureType)
|
||||||
#define Task_CheckExact(obj) (Py_TYPE(obj) == &TaskType)
|
#define Task_CheckExact(obj) Py_IS_TYPE(obj, &TaskType)
|
||||||
|
|
||||||
#define Future_Check(obj) PyObject_TypeCheck(obj, &FutureType)
|
#define Future_Check(obj) PyObject_TypeCheck(obj, &FutureType)
|
||||||
#define Task_Check(obj) PyObject_TypeCheck(obj, &TaskType)
|
#define Task_Check(obj) PyObject_TypeCheck(obj, &TaskType)
|
||||||
|
@ -255,7 +255,7 @@ get_running_loop(PyObject **loop)
|
||||||
cached_running_holder_tsid = ts->id;
|
cached_running_holder_tsid = ts->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(Py_TYPE(rl) == &PyRunningLoopHolder_Type);
|
assert(Py_IS_TYPE(rl, &PyRunningLoopHolder_Type));
|
||||||
PyObject *running_loop = ((PyRunningLoopHolder *)rl)->rl_loop;
|
PyObject *running_loop = ((PyRunningLoopHolder *)rl)->rl_loop;
|
||||||
|
|
||||||
if (running_loop == Py_None) {
|
if (running_loop == Py_None) {
|
||||||
|
|
|
@ -106,7 +106,7 @@ typedef struct {
|
||||||
|
|
||||||
static PyTypeObject Reader_Type;
|
static PyTypeObject Reader_Type;
|
||||||
|
|
||||||
#define ReaderObject_Check(v) (Py_TYPE(v) == &Reader_Type)
|
#define ReaderObject_Check(v) Py_IS_TYPE(v, &Reader_Type)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PyObject_HEAD
|
PyObject_HEAD
|
||||||
|
|
|
@ -68,7 +68,7 @@ typedef struct {
|
||||||
ffi_type *atypes[1];
|
ffi_type *atypes[1];
|
||||||
} CThunkObject;
|
} CThunkObject;
|
||||||
extern PyTypeObject PyCThunk_Type;
|
extern PyTypeObject PyCThunk_Type;
|
||||||
#define CThunk_CheckExact(v) (Py_TYPE(v) == &PyCThunk_Type)
|
#define CThunk_CheckExact(v) Py_IS_TYPE(v, &PyCThunk_Type)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* First part identical to tagCDataObject */
|
/* First part identical to tagCDataObject */
|
||||||
|
@ -102,7 +102,7 @@ typedef struct {
|
||||||
} PyCFuncPtrObject;
|
} PyCFuncPtrObject;
|
||||||
|
|
||||||
extern PyTypeObject PyCStgDict_Type;
|
extern PyTypeObject PyCStgDict_Type;
|
||||||
#define PyCStgDict_CheckExact(v) (Py_TYPE(v) == &PyCStgDict_Type)
|
#define PyCStgDict_CheckExact(v) Py_IS_TYPE(v, &PyCStgDict_Type)
|
||||||
#define PyCStgDict_Check(v) PyObject_TypeCheck(v, &PyCStgDict_Type)
|
#define PyCStgDict_Check(v) PyObject_TypeCheck(v, &PyCStgDict_Type)
|
||||||
|
|
||||||
extern int PyCStructUnionType_update_stgdict(PyObject *fields, PyObject *type, int isStruct);
|
extern int PyCStructUnionType_update_stgdict(PyObject *fields, PyObject *type, int isStruct);
|
||||||
|
@ -112,12 +112,12 @@ extern int PyObject_stginfo(PyObject *self, Py_ssize_t *psize, Py_ssize_t *palig
|
||||||
|
|
||||||
|
|
||||||
extern PyTypeObject PyCData_Type;
|
extern PyTypeObject PyCData_Type;
|
||||||
#define CDataObject_CheckExact(v) (Py_TYPE(v) == &PyCData_Type)
|
#define CDataObject_CheckExact(v) Py_IS_TYPE(v, &PyCData_Type)
|
||||||
#define CDataObject_Check(v) PyObject_TypeCheck(v, &PyCData_Type)
|
#define CDataObject_Check(v) PyObject_TypeCheck(v, &PyCData_Type)
|
||||||
#define _CDataObject_HasExternalBuffer(v) ((v)->b_ptr != (char *)&(v)->b_value)
|
#define _CDataObject_HasExternalBuffer(v) ((v)->b_ptr != (char *)&(v)->b_value)
|
||||||
|
|
||||||
extern PyTypeObject PyCSimpleType_Type;
|
extern PyTypeObject PyCSimpleType_Type;
|
||||||
#define PyCSimpleTypeObject_CheckExact(v) (Py_TYPE(v) == &PyCSimpleType_Type)
|
#define PyCSimpleTypeObject_CheckExact(v) Py_IS_TYPE(v, &PyCSimpleType_Type)
|
||||||
#define PyCSimpleTypeObject_Check(v) PyObject_TypeCheck(v, &PyCSimpleType_Type)
|
#define PyCSimpleTypeObject_Check(v) PyObject_TypeCheck(v, &PyCSimpleType_Type)
|
||||||
|
|
||||||
extern PyTypeObject PyCField_Type;
|
extern PyTypeObject PyCField_Type;
|
||||||
|
@ -314,7 +314,7 @@ struct tagPyCArgObject {
|
||||||
};
|
};
|
||||||
|
|
||||||
extern PyTypeObject PyCArg_Type;
|
extern PyTypeObject PyCArg_Type;
|
||||||
#define PyCArg_CheckExact(v) (Py_TYPE(v) == &PyCArg_Type)
|
#define PyCArg_CheckExact(v) Py_IS_TYPE(v, &PyCArg_Type)
|
||||||
extern PyCArgObject *PyCArgObject_new(void);
|
extern PyCArgObject *PyCArgObject_new(void);
|
||||||
|
|
||||||
extern PyObject *
|
extern PyObject *
|
||||||
|
|
|
@ -231,7 +231,7 @@ MakeFields(PyObject *type, CFieldObject *descr,
|
||||||
Py_DECREF(fieldlist);
|
Py_DECREF(fieldlist);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (Py_TYPE(fdescr) != &PyCField_Type) {
|
if (!Py_IS_TYPE(fdescr, &PyCField_Type)) {
|
||||||
PyErr_SetString(PyExc_TypeError, "unexpected type");
|
PyErr_SetString(PyExc_TypeError, "unexpected type");
|
||||||
Py_DECREF(fdescr);
|
Py_DECREF(fdescr);
|
||||||
Py_DECREF(fieldlist);
|
Py_DECREF(fieldlist);
|
||||||
|
@ -254,7 +254,7 @@ MakeFields(PyObject *type, CFieldObject *descr,
|
||||||
Py_DECREF(fieldlist);
|
Py_DECREF(fieldlist);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
assert(Py_TYPE(new_descr) == &PyCField_Type);
|
assert(Py_IS_TYPE(new_descr, &PyCField_Type));
|
||||||
new_descr->size = fdescr->size;
|
new_descr->size = fdescr->size;
|
||||||
new_descr->offset = fdescr->offset + offset;
|
new_descr->offset = fdescr->offset + offset;
|
||||||
new_descr->index = fdescr->index + index;
|
new_descr->index = fdescr->index + index;
|
||||||
|
@ -304,7 +304,7 @@ MakeAnonFields(PyObject *type)
|
||||||
Py_DECREF(anon_names);
|
Py_DECREF(anon_names);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (Py_TYPE(descr) != &PyCField_Type) {
|
if (!Py_IS_TYPE(descr, &PyCField_Type)) {
|
||||||
PyErr_Format(PyExc_AttributeError,
|
PyErr_Format(PyExc_AttributeError,
|
||||||
"'%U' is specified in _anonymous_ but not in "
|
"'%U' is specified in _anonymous_ but not in "
|
||||||
"_fields_",
|
"_fields_",
|
||||||
|
|
|
@ -83,7 +83,7 @@ typedef struct {
|
||||||
} PyCursesPanelObject;
|
} PyCursesPanelObject;
|
||||||
|
|
||||||
#define PyCursesPanel_Check(v) \
|
#define PyCursesPanel_Check(v) \
|
||||||
(Py_TYPE(v) == _curses_panelstate_global->PyCursesPanel_Type)
|
Py_IS_TYPE(v, _curses_panelstate_global->PyCursesPanel_Type)
|
||||||
|
|
||||||
/* Some helper functions. The problem is that there's always a window
|
/* Some helper functions. The problem is that there's always a window
|
||||||
associated with a panel. To ensure that Python's GC doesn't pull
|
associated with a panel. To ensure that Python's GC doesn't pull
|
||||||
|
|
|
@ -18,19 +18,19 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PyDate_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateType)
|
#define PyDate_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateType)
|
||||||
#define PyDate_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateType)
|
#define PyDate_CheckExact(op) Py_IS_TYPE(op, &PyDateTime_DateType)
|
||||||
|
|
||||||
#define PyDateTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateTimeType)
|
#define PyDateTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateTimeType)
|
||||||
#define PyDateTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateTimeType)
|
#define PyDateTime_CheckExact(op) Py_IS_TYPE(op, &PyDateTime_DateTimeType)
|
||||||
|
|
||||||
#define PyTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_TimeType)
|
#define PyTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_TimeType)
|
||||||
#define PyTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TimeType)
|
#define PyTime_CheckExact(op) Py_IS_TYPE(op, &PyDateTime_TimeType)
|
||||||
|
|
||||||
#define PyDelta_Check(op) PyObject_TypeCheck(op, &PyDateTime_DeltaType)
|
#define PyDelta_Check(op) PyObject_TypeCheck(op, &PyDateTime_DeltaType)
|
||||||
#define PyDelta_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DeltaType)
|
#define PyDelta_CheckExact(op) Py_IS_TYPE(op, &PyDateTime_DeltaType)
|
||||||
|
|
||||||
#define PyTZInfo_Check(op) PyObject_TypeCheck(op, &PyDateTime_TZInfoType)
|
#define PyTZInfo_Check(op) PyObject_TypeCheck(op, &PyDateTime_TZInfoType)
|
||||||
#define PyTZInfo_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TZInfoType)
|
#define PyTZInfo_CheckExact(op) Py_IS_TYPE(op, &PyDateTime_TZInfoType)
|
||||||
|
|
||||||
#define PyTimezone_Check(op) PyObject_TypeCheck(op, &PyDateTime_TimeZoneType)
|
#define PyTimezone_Check(op) PyObject_TypeCheck(op, &PyDateTime_TimeZoneType)
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ typedef struct {
|
||||||
|
|
||||||
static PyTypeObject Dbmtype;
|
static PyTypeObject Dbmtype;
|
||||||
|
|
||||||
#define is_dbmobject(v) (Py_TYPE(v) == &Dbmtype)
|
#define is_dbmobject(v) Py_IS_TYPE(v, &Dbmtype)
|
||||||
#define check_dbmobject_open(v) if ((v)->di_dbm == NULL) \
|
#define check_dbmobject_open(v) if ((v)->di_dbm == NULL) \
|
||||||
{ PyErr_SetString(DbmError, "DBM object has already been closed"); \
|
{ PyErr_SetString(DbmError, "DBM object has already been closed"); \
|
||||||
return NULL; }
|
return NULL; }
|
||||||
|
|
|
@ -96,9 +96,9 @@ static PyTypeObject PyDec_Type;
|
||||||
static PyTypeObject *PyDecSignalDict_Type;
|
static PyTypeObject *PyDecSignalDict_Type;
|
||||||
static PyTypeObject PyDecContext_Type;
|
static PyTypeObject PyDecContext_Type;
|
||||||
static PyTypeObject PyDecContextManager_Type;
|
static PyTypeObject PyDecContextManager_Type;
|
||||||
#define PyDec_CheckExact(v) (Py_TYPE(v) == &PyDec_Type)
|
#define PyDec_CheckExact(v) Py_IS_TYPE(v, &PyDec_Type)
|
||||||
#define PyDec_Check(v) PyObject_TypeCheck(v, &PyDec_Type)
|
#define PyDec_Check(v) PyObject_TypeCheck(v, &PyDec_Type)
|
||||||
#define PyDecSignalDict_Check(v) (Py_TYPE(v) == PyDecSignalDict_Type)
|
#define PyDecSignalDict_Check(v) Py_IS_TYPE(v, PyDecSignalDict_Type)
|
||||||
#define PyDecContext_Check(v) PyObject_TypeCheck(v, &PyDecContext_Type)
|
#define PyDecContext_Check(v) PyObject_TypeCheck(v, &PyDecContext_Type)
|
||||||
#define MPD(v) (&((PyDecObject *)v)->dec)
|
#define MPD(v) (&((PyDecObject *)v)->dec)
|
||||||
#define SdFlagAddr(v) (((PyDecSignalDictObject *)v)->flags)
|
#define SdFlagAddr(v) (((PyDecSignalDictObject *)v)->flags)
|
||||||
|
|
|
@ -209,7 +209,7 @@ typedef struct {
|
||||||
} ElementObject;
|
} ElementObject;
|
||||||
|
|
||||||
|
|
||||||
#define Element_CheckExact(op) (Py_TYPE(op) == &Element_Type)
|
#define Element_CheckExact(op) Py_IS_TYPE(op, &Element_Type)
|
||||||
#define Element_Check(op) PyObject_TypeCheck(op, &Element_Type)
|
#define Element_Check(op) PyObject_TypeCheck(op, &Element_Type)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ partial_new(PyTypeObject *type, PyObject *args, PyObject *kw)
|
||||||
|
|
||||||
pargs = pkw = NULL;
|
pargs = pkw = NULL;
|
||||||
func = PyTuple_GET_ITEM(args, 0);
|
func = PyTuple_GET_ITEM(args, 0);
|
||||||
if (Py_TYPE(func) == &partial_type && type == &partial_type) {
|
if (Py_IS_TYPE(func, &partial_type) && type == &partial_type) {
|
||||||
partialobject *part = (partialobject *)func;
|
partialobject *part = (partialobject *)func;
|
||||||
if (part->dict == NULL) {
|
if (part->dict == NULL) {
|
||||||
pargs = part->args;
|
pargs = part->args;
|
||||||
|
|
|
@ -44,7 +44,7 @@ static PyTypeObject Dbmtype;
|
||||||
|
|
||||||
#include "clinic/_gdbmmodule.c.h"
|
#include "clinic/_gdbmmodule.c.h"
|
||||||
|
|
||||||
#define is_dbmobject(v) (Py_TYPE(v) == &Dbmtype)
|
#define is_dbmobject(v) Py_IS_TYPE(v, &Dbmtype)
|
||||||
#define check_dbmobject_open(v) if ((v)->di_dbm == NULL) \
|
#define check_dbmobject_open(v) if ((v)->di_dbm == NULL) \
|
||||||
{ PyErr_SetString(DbmError, "GDBM object has already been closed"); \
|
{ PyErr_SetString(DbmError, "GDBM object has already been closed"); \
|
||||||
return NULL; }
|
return NULL; }
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
#include "pycore_accu.h"
|
#include "pycore_accu.h"
|
||||||
|
|
||||||
#define PyScanner_Check(op) PyObject_TypeCheck(op, &PyScannerType)
|
#define PyScanner_Check(op) PyObject_TypeCheck(op, &PyScannerType)
|
||||||
#define PyScanner_CheckExact(op) (Py_TYPE(op) == &PyScannerType)
|
#define PyScanner_CheckExact(op) Py_IS_TYPE(op, &PyScannerType)
|
||||||
#define PyEncoder_Check(op) PyObject_TypeCheck(op, &PyEncoderType)
|
#define PyEncoder_Check(op) PyObject_TypeCheck(op, &PyEncoderType)
|
||||||
#define PyEncoder_CheckExact(op) (Py_TYPE(op) == &PyEncoderType)
|
#define PyEncoder_CheckExact(op) Py_IS_TYPE(op, &PyEncoderType)
|
||||||
|
|
||||||
static PyTypeObject PyScannerType;
|
static PyTypeObject PyScannerType;
|
||||||
static PyTypeObject PyEncoderType;
|
static PyTypeObject PyEncoderType;
|
||||||
|
|
|
@ -54,7 +54,7 @@ typedef struct {
|
||||||
static PyTypeObject PyProfiler_Type;
|
static PyTypeObject PyProfiler_Type;
|
||||||
|
|
||||||
#define PyProfiler_Check(op) PyObject_TypeCheck(op, &PyProfiler_Type)
|
#define PyProfiler_Check(op) PyObject_TypeCheck(op, &PyProfiler_Type)
|
||||||
#define PyProfiler_CheckExact(op) (Py_TYPE(op) == &PyProfiler_Type)
|
#define PyProfiler_CheckExact(op) Py_IS_TYPE(op, &PyProfiler_Type)
|
||||||
|
|
||||||
/*** External Timers ***/
|
/*** External Timers ***/
|
||||||
|
|
||||||
|
|
|
@ -2518,7 +2518,7 @@ pattern_richcompare(PyObject *lefto, PyObject *righto, int op)
|
||||||
Py_RETURN_NOTIMPLEMENTED;
|
Py_RETURN_NOTIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Py_TYPE(lefto) != &Pattern_Type || Py_TYPE(righto) != &Pattern_Type) {
|
if (!Py_IS_TYPE(lefto, &Pattern_Type) || !Py_IS_TYPE(righto, &Pattern_Type)) {
|
||||||
Py_RETURN_NOTIMPLEMENTED;
|
Py_RETURN_NOTIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -508,9 +508,9 @@ static int PySSL_select(PySocketSockObject *s, int writing, _PyTime_t timeout);
|
||||||
|
|
||||||
static int PySSL_set_owner(PySSLSocket *, PyObject *, void *);
|
static int PySSL_set_owner(PySSLSocket *, PyObject *, void *);
|
||||||
static int PySSL_set_session(PySSLSocket *, PyObject *, void *);
|
static int PySSL_set_session(PySSLSocket *, PyObject *, void *);
|
||||||
#define PySSLSocket_Check(v) (Py_TYPE(v) == &PySSLSocket_Type)
|
#define PySSLSocket_Check(v) Py_IS_TYPE(v, &PySSLSocket_Type)
|
||||||
#define PySSLMemoryBIO_Check(v) (Py_TYPE(v) == &PySSLMemoryBIO_Type)
|
#define PySSLMemoryBIO_Check(v) Py_IS_TYPE(v, &PySSLMemoryBIO_Type)
|
||||||
#define PySSLSession_Check(v) (Py_TYPE(v) == &PySSLSession_Type)
|
#define PySSLSession_Check(v) Py_IS_TYPE(v, &PySSLSession_Type)
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SOCKET_IS_NONBLOCKING,
|
SOCKET_IS_NONBLOCKING,
|
||||||
|
|
|
@ -57,7 +57,7 @@ typedef struct {
|
||||||
|
|
||||||
|
|
||||||
#define PyStruct_Check(op) PyObject_TypeCheck(op, (PyTypeObject *)_structmodulestate_global->PyStructType)
|
#define PyStruct_Check(op) PyObject_TypeCheck(op, (PyTypeObject *)_structmodulestate_global->PyStructType)
|
||||||
#define PyStruct_CheckExact(op) (Py_TYPE(op) == (PyTypeObject *)_structmodulestate_global->PyStructType)
|
#define PyStruct_CheckExact(op) Py_IS_TYPE(op, (PyTypeObject *)_structmodulestate_global->PyStructType)
|
||||||
|
|
||||||
|
|
||||||
/* Define various structs to figure out the alignments of types */
|
/* Define various structs to figure out the alignments of types */
|
||||||
|
|
|
@ -24,7 +24,7 @@ static PyObject *simple_format = NULL;
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
static PyTypeObject NDArray_Type;
|
static PyTypeObject NDArray_Type;
|
||||||
#define NDArray_Check(v) (Py_TYPE(v) == &NDArray_Type)
|
#define NDArray_Check(v) Py_IS_TYPE(v, &NDArray_Type)
|
||||||
|
|
||||||
#define CHECK_LIST_OR_TUPLE(v) \
|
#define CHECK_LIST_OR_TUPLE(v) \
|
||||||
if (!PyList_Check(v) && !PyTuple_Check(v)) { \
|
if (!PyList_Check(v) && !PyTuple_Check(v)) { \
|
||||||
|
|
|
@ -833,7 +833,7 @@ typedef struct {
|
||||||
} PyTclObject;
|
} PyTclObject;
|
||||||
|
|
||||||
static PyObject *PyTclObject_Type;
|
static PyObject *PyTclObject_Type;
|
||||||
#define PyTclObject_Check(v) (Py_TYPE(v) == (PyTypeObject *) PyTclObject_Type)
|
#define PyTclObject_Check(v) Py_IS_TYPE(v, (PyTypeObject *) PyTclObject_Type)
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
newPyTclObject(Tcl_Obj *arg)
|
newPyTclObject(Tcl_Obj *arg)
|
||||||
|
|
|
@ -106,7 +106,7 @@ enum machine_format_code {
|
||||||
#include "clinic/arraymodule.c.h"
|
#include "clinic/arraymodule.c.h"
|
||||||
|
|
||||||
#define array_Check(op) PyObject_TypeCheck(op, &Arraytype)
|
#define array_Check(op) PyObject_TypeCheck(op, &Arraytype)
|
||||||
#define array_CheckExact(op) (Py_TYPE(op) == &Arraytype)
|
#define array_CheckExact(op) Py_IS_TYPE(op, &Arraytype)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
array_resize(arrayobject *self, Py_ssize_t newsize)
|
array_resize(arrayobject *self, Py_ssize_t newsize)
|
||||||
|
|
|
@ -256,7 +256,7 @@ PyTypeObject PyST_Type = {
|
||||||
|
|
||||||
|
|
||||||
/* PyST_Type isn't subclassable, so just check ob_type */
|
/* PyST_Type isn't subclassable, so just check ob_type */
|
||||||
#define PyST_Object_Check(v) (Py_TYPE(v) == &PyST_Type)
|
#define PyST_Object_Check(v) Py_IS_TYPE(v, &PyST_Type)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
parser_compare_nodes(node *left, node *right)
|
parser_compare_nodes(node *left, node *right)
|
||||||
|
|
|
@ -413,7 +413,7 @@ SHA256Type_copy_impl(SHAobject *self)
|
||||||
{
|
{
|
||||||
SHAobject *newobj;
|
SHAobject *newobj;
|
||||||
|
|
||||||
if (Py_TYPE(self) == &SHA256type) {
|
if (Py_IS_TYPE(self, &SHA256type)) {
|
||||||
if ( (newobj = newSHA256object())==NULL)
|
if ( (newobj = newSHA256object())==NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -478,7 +478,7 @@ SHA512Type_copy_impl(SHAobject *self)
|
||||||
{
|
{
|
||||||
SHAobject *newobj;
|
SHAobject *newobj;
|
||||||
|
|
||||||
if (Py_TYPE((PyObject*)self) == &SHA512type) {
|
if (Py_IS_TYPE((PyObject*)self, &SHA512type)) {
|
||||||
if ( (newobj = newSHA512object())==NULL)
|
if ( (newobj = newSHA512object())==NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -550,7 +550,7 @@ gettmarg(PyObject *args, struct tm *p, const char *format)
|
||||||
p->tm_wday = (p->tm_wday + 1) % 7;
|
p->tm_wday = (p->tm_wday + 1) % 7;
|
||||||
p->tm_yday--;
|
p->tm_yday--;
|
||||||
#ifdef HAVE_STRUCT_TM_TM_ZONE
|
#ifdef HAVE_STRUCT_TM_TM_ZONE
|
||||||
if (Py_TYPE(args) == &StructTimeType) {
|
if (Py_IS_TYPE(args, &StructTimeType)) {
|
||||||
PyObject *item;
|
PyObject *item;
|
||||||
item = PyStructSequence_GET_ITEM(args, 9);
|
item = PyStructSequence_GET_ITEM(args, 9);
|
||||||
if (item != Py_None) {
|
if (item != Py_None) {
|
||||||
|
|
|
@ -92,7 +92,7 @@ static PyMemberDef DB_members[] = {
|
||||||
|
|
||||||
/* forward declaration */
|
/* forward declaration */
|
||||||
static PyTypeObject UCD_Type;
|
static PyTypeObject UCD_Type;
|
||||||
#define UCD_Check(o) (Py_TYPE(o)==&UCD_Type)
|
#define UCD_Check(o) Py_IS_TYPE(o, &UCD_Type)
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
new_previous_version(const char*name, const change_record* (*getrecord)(Py_UCS4),
|
new_previous_version(const char*name, const change_record* (*getrecord)(Py_UCS4),
|
||||||
|
|
|
@ -25,7 +25,7 @@ typedef struct {
|
||||||
|
|
||||||
static PyObject *Xxo_Type;
|
static PyObject *Xxo_Type;
|
||||||
|
|
||||||
#define XxoObject_Check(v) (Py_TYPE(v) == Xxo_Type)
|
#define XxoObject_Check(v) Py_IS_TYPE(v, Xxo_Type)
|
||||||
|
|
||||||
static XxoObject *
|
static XxoObject *
|
||||||
newXxoObject(PyObject *arg)
|
newXxoObject(PyObject *arg)
|
||||||
|
|
|
@ -25,7 +25,7 @@ typedef struct {
|
||||||
|
|
||||||
static PyTypeObject Xxo_Type;
|
static PyTypeObject Xxo_Type;
|
||||||
|
|
||||||
#define XxoObject_Check(v) (Py_TYPE(v) == &Xxo_Type)
|
#define XxoObject_Check(v) Py_IS_TYPE(v, &Xxo_Type)
|
||||||
|
|
||||||
static XxoObject *
|
static XxoObject *
|
||||||
newXxoObject(PyObject *arg)
|
newXxoObject(PyObject *arg)
|
||||||
|
|
|
@ -37,7 +37,7 @@ static PyObject *
|
||||||
method_vectorcall(PyObject *method, PyObject *const *args,
|
method_vectorcall(PyObject *method, PyObject *const *args,
|
||||||
size_t nargsf, PyObject *kwnames)
|
size_t nargsf, PyObject *kwnames)
|
||||||
{
|
{
|
||||||
assert(Py_TYPE(method) == &PyMethod_Type);
|
assert(Py_IS_TYPE(method, &PyMethod_Type));
|
||||||
|
|
||||||
PyThreadState *tstate = _PyThreadState_GET();
|
PyThreadState *tstate = _PyThreadState_GET();
|
||||||
PyObject *self = PyMethod_GET_SELF(method);
|
PyObject *self = PyMethod_GET_SELF(method);
|
||||||
|
|
|
@ -608,7 +608,7 @@ new_dict(PyDictKeysObject *keys, PyObject **values)
|
||||||
if (numfree) {
|
if (numfree) {
|
||||||
mp = free_list[--numfree];
|
mp = free_list[--numfree];
|
||||||
assert (mp != NULL);
|
assert (mp != NULL);
|
||||||
assert (Py_TYPE(mp) == &PyDict_Type);
|
assert (Py_IS_TYPE(mp, &PyDict_Type));
|
||||||
_Py_NewReference((PyObject *)mp);
|
_Py_NewReference((PyObject *)mp);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -2007,7 +2007,7 @@ dict_dealloc(PyDictObject *mp)
|
||||||
assert(keys->dk_refcnt == 1);
|
assert(keys->dk_refcnt == 1);
|
||||||
dictkeys_decref(keys);
|
dictkeys_decref(keys);
|
||||||
}
|
}
|
||||||
if (numfree < PyDict_MAXFREELIST && Py_TYPE(mp) == &PyDict_Type)
|
if (numfree < PyDict_MAXFREELIST && Py_IS_TYPE(mp, &PyDict_Type))
|
||||||
free_list[numfree++] = mp;
|
free_list[numfree++] = mp;
|
||||||
else
|
else
|
||||||
Py_TYPE(mp)->tp_free((PyObject *)mp);
|
Py_TYPE(mp)->tp_free((PyObject *)mp);
|
||||||
|
@ -3864,15 +3864,15 @@ dictreviter_iternext(dictiterobject *di)
|
||||||
di->di_pos = i-1;
|
di->di_pos = i-1;
|
||||||
di->len--;
|
di->len--;
|
||||||
|
|
||||||
if (Py_TYPE(di) == &PyDictRevIterKey_Type) {
|
if (Py_IS_TYPE(di, &PyDictRevIterKey_Type)) {
|
||||||
Py_INCREF(key);
|
Py_INCREF(key);
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
else if (Py_TYPE(di) == &PyDictRevIterValue_Type) {
|
else if (Py_IS_TYPE(di, &PyDictRevIterValue_Type)) {
|
||||||
Py_INCREF(value);
|
Py_INCREF(value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
else if (Py_TYPE(di) == &PyDictRevIterItem_Type) {
|
else if (Py_IS_TYPE(di, &PyDictRevIterItem_Type)) {
|
||||||
Py_INCREF(key);
|
Py_INCREF(key);
|
||||||
Py_INCREF(value);
|
Py_INCREF(value);
|
||||||
result = di->di_result;
|
result = di->di_result;
|
||||||
|
@ -4236,7 +4236,7 @@ _PyDictView_Intersect(PyObject* self, PyObject *other)
|
||||||
|
|
||||||
/* if other is a set and self is smaller than other,
|
/* if other is a set and self is smaller than other,
|
||||||
reuse set intersection logic */
|
reuse set intersection logic */
|
||||||
if (Py_TYPE(other) == &PySet_Type && len_self <= PyObject_Size(other)) {
|
if (Py_IS_TYPE(other, &PySet_Type) && len_self <= PyObject_Size(other)) {
|
||||||
_Py_IDENTIFIER(intersection);
|
_Py_IDENTIFIER(intersection);
|
||||||
return _PyObject_CallMethodIdObjArgs(other, &PyId_intersection, self, NULL);
|
return _PyObject_CallMethodIdObjArgs(other, &PyId_intersection, self, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -302,7 +302,7 @@ type_mro_modified(PyTypeObject *type, PyObject *bases) {
|
||||||
each subclass when their mro is recursively updated.
|
each subclass when their mro is recursively updated.
|
||||||
*/
|
*/
|
||||||
Py_ssize_t i, n;
|
Py_ssize_t i, n;
|
||||||
int custom = (Py_TYPE(type) != &PyType_Type);
|
int custom = !Py_IS_TYPE(type, &PyType_Type);
|
||||||
int unbound;
|
int unbound;
|
||||||
PyObject *mro_meth = NULL;
|
PyObject *mro_meth = NULL;
|
||||||
PyObject *type_mro_meth = NULL;
|
PyObject *type_mro_meth = NULL;
|
||||||
|
|
|
@ -274,9 +274,9 @@ to introspect the tree:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#define IS_ARRAY_NODE(node) (Py_TYPE(node) == &_PyHamt_ArrayNode_Type)
|
#define IS_ARRAY_NODE(node) Py_IS_TYPE(node, &_PyHamt_ArrayNode_Type)
|
||||||
#define IS_BITMAP_NODE(node) (Py_TYPE(node) == &_PyHamt_BitmapNode_Type)
|
#define IS_BITMAP_NODE(node) Py_IS_TYPE(node, &_PyHamt_BitmapNode_Type)
|
||||||
#define IS_COLLISION_NODE(node) (Py_TYPE(node) == &_PyHamt_CollisionNode_Type)
|
#define IS_COLLISION_NODE(node) Py_IS_TYPE(node, &_PyHamt_CollisionNode_Type)
|
||||||
|
|
||||||
|
|
||||||
/* Return type for 'find' (lookup a key) functions.
|
/* Return type for 'find' (lookup a key) functions.
|
||||||
|
|
Loading…
Reference in New Issue