diff options
author | Dong-hee Na <donghee.na92@gmail.com> | 2020-02-17 10:09:15 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-17 10:09:15 (GMT) |
commit | 1b55b65638254aa78b005fbf0b71fb02499f1852 (patch) | |
tree | 3c9a1a7b47443d75d73a57002ecb3a49ae88ce2c /Modules | |
parent | a7847590f07655e794d7c62130aea245a110acef (diff) | |
download | cpython-1b55b65638254aa78b005fbf0b71fb02499f1852.zip cpython-1b55b65638254aa78b005fbf0b71fb02499f1852.tar.gz cpython-1b55b65638254aa78b005fbf0b71fb02499f1852.tar.bz2 |
bpo-39573: Clean up modules and headers to use Py_IS_TYPE() function (GH-18521)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_abc.c | 2 | ||||
-rw-r--r-- | Modules/_asynciomodule.c | 6 | ||||
-rw-r--r-- | Modules/_csv.c | 2 | ||||
-rw-r--r-- | Modules/_ctypes/ctypes.h | 10 | ||||
-rw-r--r-- | Modules/_ctypes/stgdict.c | 6 | ||||
-rw-r--r-- | Modules/_curses_panel.c | 2 | ||||
-rw-r--r-- | Modules/_datetimemodule.c | 10 | ||||
-rw-r--r-- | Modules/_dbmmodule.c | 2 | ||||
-rw-r--r-- | Modules/_decimal/_decimal.c | 4 | ||||
-rw-r--r-- | Modules/_elementtree.c | 2 | ||||
-rw-r--r-- | Modules/_functoolsmodule.c | 2 | ||||
-rw-r--r-- | Modules/_gdbmmodule.c | 2 | ||||
-rw-r--r-- | Modules/_json.c | 4 | ||||
-rw-r--r-- | Modules/_lsprof.c | 2 | ||||
-rw-r--r-- | Modules/_sre.c | 2 | ||||
-rw-r--r-- | Modules/_ssl.c | 6 | ||||
-rw-r--r-- | Modules/_struct.c | 2 | ||||
-rw-r--r-- | Modules/_testbuffer.c | 2 | ||||
-rw-r--r-- | Modules/_tkinter.c | 2 | ||||
-rw-r--r-- | Modules/arraymodule.c | 2 | ||||
-rw-r--r-- | Modules/parsermodule.c | 2 | ||||
-rw-r--r-- | Modules/sha256module.c | 2 | ||||
-rw-r--r-- | Modules/sha512module.c | 2 | ||||
-rw-r--r-- | Modules/timemodule.c | 2 | ||||
-rw-r--r-- | Modules/unicodedata.c | 2 | ||||
-rw-r--r-- | Modules/xxlimited.c | 2 | ||||
-rw-r--r-- | Modules/xxmodule.c | 2 |
27 files changed, 43 insertions, 43 deletions
diff --git a/Modules/_abc.c b/Modules/_abc.c index 7b5d418..e21fe78 100644 --- a/Modules/_abc.c +++ b/Modules/_abc.c @@ -82,7 +82,7 @@ _get_impl(PyObject *self) if (impl == 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"); Py_DECREF(impl); return NULL; diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c index 5aea743..5674330 100644 --- a/Modules/_asynciomodule.c +++ b/Modules/_asynciomodule.c @@ -112,8 +112,8 @@ static PyTypeObject TaskType; static PyTypeObject PyRunningLoopHolder_Type; -#define Future_CheckExact(obj) (Py_TYPE(obj) == &FutureType) -#define Task_CheckExact(obj) (Py_TYPE(obj) == &TaskType) +#define Future_CheckExact(obj) Py_IS_TYPE(obj, &FutureType) +#define Task_CheckExact(obj) Py_IS_TYPE(obj, &TaskType) #define Future_Check(obj) PyObject_TypeCheck(obj, &FutureType) #define Task_Check(obj) PyObject_TypeCheck(obj, &TaskType) @@ -255,7 +255,7 @@ get_running_loop(PyObject **loop) 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; if (running_loop == Py_None) { diff --git a/Modules/_csv.c b/Modules/_csv.c index 4243772..f820f55 100644 --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -106,7 +106,7 @@ typedef struct { 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 { PyObject_HEAD diff --git a/Modules/_ctypes/ctypes.h b/Modules/_ctypes/ctypes.h index a93d573..1effccf 100644 --- a/Modules/_ctypes/ctypes.h +++ b/Modules/_ctypes/ctypes.h @@ -68,7 +68,7 @@ typedef struct { ffi_type *atypes[1]; } CThunkObject; 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 { /* First part identical to tagCDataObject */ @@ -102,7 +102,7 @@ typedef struct { } PyCFuncPtrObject; 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) 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; -#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_HasExternalBuffer(v) ((v)->b_ptr != (char *)&(v)->b_value) 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) extern PyTypeObject PyCField_Type; @@ -314,7 +314,7 @@ struct tagPyCArgObject { }; 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 PyObject * diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c index c8001a9..443951a 100644 --- a/Modules/_ctypes/stgdict.c +++ b/Modules/_ctypes/stgdict.c @@ -231,7 +231,7 @@ MakeFields(PyObject *type, CFieldObject *descr, Py_DECREF(fieldlist); return -1; } - if (Py_TYPE(fdescr) != &PyCField_Type) { + if (!Py_IS_TYPE(fdescr, &PyCField_Type)) { PyErr_SetString(PyExc_TypeError, "unexpected type"); Py_DECREF(fdescr); Py_DECREF(fieldlist); @@ -254,7 +254,7 @@ MakeFields(PyObject *type, CFieldObject *descr, Py_DECREF(fieldlist); return -1; } - assert(Py_TYPE(new_descr) == &PyCField_Type); + assert(Py_IS_TYPE(new_descr, &PyCField_Type)); new_descr->size = fdescr->size; new_descr->offset = fdescr->offset + offset; new_descr->index = fdescr->index + index; @@ -304,7 +304,7 @@ MakeAnonFields(PyObject *type) Py_DECREF(anon_names); return -1; } - if (Py_TYPE(descr) != &PyCField_Type) { + if (!Py_IS_TYPE(descr, &PyCField_Type)) { PyErr_Format(PyExc_AttributeError, "'%U' is specified in _anonymous_ but not in " "_fields_", diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c index 53849e3..c18af7e 100644 --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -83,7 +83,7 @@ typedef struct { } PyCursesPanelObject; #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 associated with a panel. To ensure that Python's GC doesn't pull diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index bc03c50..4cafd14 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -18,19 +18,19 @@ #endif #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_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_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_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_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) diff --git a/Modules/_dbmmodule.c b/Modules/_dbmmodule.c index 072e977..80a0503 100644 --- a/Modules/_dbmmodule.c +++ b/Modules/_dbmmodule.c @@ -45,7 +45,7 @@ typedef struct { 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) \ { PyErr_SetString(DbmError, "DBM object has already been closed"); \ return NULL; } diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c index 0fbbb73..e2f6ea1 100644 --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -96,9 +96,9 @@ static PyTypeObject PyDec_Type; static PyTypeObject *PyDecSignalDict_Type; static PyTypeObject PyDecContext_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 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 MPD(v) (&((PyDecObject *)v)->dec) #define SdFlagAddr(v) (((PyDecSignalDictObject *)v)->flags) diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c index a04b295..4498c5f 100644 --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -209,7 +209,7 @@ typedef struct { } 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) diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c index 88c02d8..ab0839c 100644 --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -41,7 +41,7 @@ partial_new(PyTypeObject *type, PyObject *args, PyObject *kw) pargs = pkw = NULL; 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; if (part->dict == NULL) { pargs = part->args; diff --git a/Modules/_gdbmmodule.c b/Modules/_gdbmmodule.c index a815819..7a9649b 100644 --- a/Modules/_gdbmmodule.c +++ b/Modules/_gdbmmodule.c @@ -44,7 +44,7 @@ static PyTypeObject Dbmtype; #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) \ { PyErr_SetString(DbmError, "GDBM object has already been closed"); \ return NULL; } diff --git a/Modules/_json.c b/Modules/_json.c index ee2070c..d9346a7 100644 --- a/Modules/_json.c +++ b/Modules/_json.c @@ -13,9 +13,9 @@ #include "pycore_accu.h" #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_CheckExact(op) (Py_TYPE(op) == &PyEncoderType) +#define PyEncoder_CheckExact(op) Py_IS_TYPE(op, &PyEncoderType) static PyTypeObject PyScannerType; static PyTypeObject PyEncoderType; diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c index c5a6f44..2718c61 100644 --- a/Modules/_lsprof.c +++ b/Modules/_lsprof.c @@ -54,7 +54,7 @@ typedef struct { static PyTypeObject 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 ***/ diff --git a/Modules/_sre.c b/Modules/_sre.c index 80c4184..15950c6 100644 --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -2518,7 +2518,7 @@ pattern_richcompare(PyObject *lefto, PyObject *righto, int op) 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; } diff --git a/Modules/_ssl.c b/Modules/_ssl.c index a0d34b3..ef04712 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -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_session(PySSLSocket *, PyObject *, void *); -#define PySSLSocket_Check(v) (Py_TYPE(v) == &PySSLSocket_Type) -#define PySSLMemoryBIO_Check(v) (Py_TYPE(v) == &PySSLMemoryBIO_Type) -#define PySSLSession_Check(v) (Py_TYPE(v) == &PySSLSession_Type) +#define PySSLSocket_Check(v) Py_IS_TYPE(v, &PySSLSocket_Type) +#define PySSLMemoryBIO_Check(v) Py_IS_TYPE(v, &PySSLMemoryBIO_Type) +#define PySSLSession_Check(v) Py_IS_TYPE(v, &PySSLSession_Type) typedef enum { SOCKET_IS_NONBLOCKING, diff --git a/Modules/_struct.c b/Modules/_struct.c index 0cdfe26..eed3659 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -57,7 +57,7 @@ typedef struct { #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 */ diff --git a/Modules/_testbuffer.c b/Modules/_testbuffer.c index 600a52a..f4c2b59 100644 --- a/Modules/_testbuffer.c +++ b/Modules/_testbuffer.c @@ -24,7 +24,7 @@ static PyObject *simple_format = NULL; /**************************************************************************/ 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) \ if (!PyList_Check(v) && !PyTuple_Check(v)) { \ diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index 87bc7ae..5f001c6 100644 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -833,7 +833,7 @@ typedef struct { } PyTclObject; 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 * newPyTclObject(Tcl_Obj *arg) diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index eeda714..b41ba05 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -106,7 +106,7 @@ enum machine_format_code { #include "clinic/arraymodule.c.h" #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 array_resize(arrayobject *self, Py_ssize_t newsize) diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c index f00329b..24b0ffb 100644 --- a/Modules/parsermodule.c +++ b/Modules/parsermodule.c @@ -256,7 +256,7 @@ PyTypeObject PyST_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 parser_compare_nodes(node *left, node *right) diff --git a/Modules/sha256module.c b/Modules/sha256module.c index 0e0c446..eee582c 100644 --- a/Modules/sha256module.c +++ b/Modules/sha256module.c @@ -413,7 +413,7 @@ SHA256Type_copy_impl(SHAobject *self) { SHAobject *newobj; - if (Py_TYPE(self) == &SHA256type) { + if (Py_IS_TYPE(self, &SHA256type)) { if ( (newobj = newSHA256object())==NULL) return NULL; } else { diff --git a/Modules/sha512module.c b/Modules/sha512module.c index 07bf283..b2e0727 100644 --- a/Modules/sha512module.c +++ b/Modules/sha512module.c @@ -478,7 +478,7 @@ SHA512Type_copy_impl(SHAobject *self) { SHAobject *newobj; - if (Py_TYPE((PyObject*)self) == &SHA512type) { + if (Py_IS_TYPE((PyObject*)self, &SHA512type)) { if ( (newobj = newSHA512object())==NULL) return NULL; } else { diff --git a/Modules/timemodule.c b/Modules/timemodule.c index 5e0010c..1709720 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -550,7 +550,7 @@ gettmarg(PyObject *args, struct tm *p, const char *format) p->tm_wday = (p->tm_wday + 1) % 7; p->tm_yday--; #ifdef HAVE_STRUCT_TM_TM_ZONE - if (Py_TYPE(args) == &StructTimeType) { + if (Py_IS_TYPE(args, &StructTimeType)) { PyObject *item; item = PyStructSequence_GET_ITEM(args, 9); if (item != Py_None) { diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c index 58b1bc2..ce97bdf 100644 --- a/Modules/unicodedata.c +++ b/Modules/unicodedata.c @@ -92,7 +92,7 @@ static PyMemberDef DB_members[] = { /* forward declaration */ 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* new_previous_version(const char*name, const change_record* (*getrecord)(Py_UCS4), diff --git a/Modules/xxlimited.c b/Modules/xxlimited.c index ffc04e0..7ce0b6e 100644 --- a/Modules/xxlimited.c +++ b/Modules/xxlimited.c @@ -25,7 +25,7 @@ typedef struct { 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 * newXxoObject(PyObject *arg) diff --git a/Modules/xxmodule.c b/Modules/xxmodule.c index 0250031..17b049c 100644 --- a/Modules/xxmodule.c +++ b/Modules/xxmodule.c @@ -25,7 +25,7 @@ typedef struct { 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 * newXxoObject(PyObject *arg) |