diff options
author | Victor Stinner <vstinner@python.org> | 2020-02-07 02:37:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-07 02:37:06 (GMT) |
commit | daa9756cb6395323d6f291efe5c7d7fdc6b2e9d8 (patch) | |
tree | 363abf13e467be17feb0e3eeffc3abe73c437264 /Modules | |
parent | 58ac700fb09497df14d4492b6f820109490b2b88 (diff) | |
download | cpython-daa9756cb6395323d6f291efe5c7d7fdc6b2e9d8.zip cpython-daa9756cb6395323d6f291efe5c7d7fdc6b2e9d8.tar.gz cpython-daa9756cb6395323d6f291efe5c7d7fdc6b2e9d8.tar.bz2 |
bpo-39573: Use Py_TYPE() macro in Modules directory (GH-18393)
Replace direct access to PyObject.ob_type with Py_TYPE().
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_collectionsmodule.c | 4 | ||||
-rw-r--r-- | Modules/_csv.c | 6 | ||||
-rw-r--r-- | Modules/_ctypes/cfield.c | 14 | ||||
-rw-r--r-- | Modules/_ctypes/ctypes.h | 4 | ||||
-rw-r--r-- | Modules/_ctypes/stgdict.c | 2 | ||||
-rw-r--r-- | Modules/_cursesmodule.c | 2 | ||||
-rw-r--r-- | Modules/_datetimemodule.c | 2 | ||||
-rw-r--r-- | Modules/_dbmmodule.c | 2 | ||||
-rw-r--r-- | Modules/_decimal/_decimal.c | 6 | ||||
-rw-r--r-- | Modules/_gdbmmodule.c | 2 | ||||
-rw-r--r-- | Modules/_io/_iomodule.c | 2 | ||||
-rw-r--r-- | Modules/_io/textio.c | 2 | ||||
-rw-r--r-- | Modules/_json.c | 2 | ||||
-rw-r--r-- | Modules/_pickle.c | 2 | ||||
-rw-r--r-- | Modules/_sqlite/microprotocols.c | 2 | ||||
-rw-r--r-- | Modules/_testbuffer.c | 2 | ||||
-rw-r--r-- | Modules/_testcapimodule.c | 4 | ||||
-rw-r--r-- | Modules/_tkinter.c | 4 | ||||
-rw-r--r-- | Modules/_xxsubinterpretersmodule.c | 2 | ||||
-rw-r--r-- | Modules/cjkcodecs/multibytecodec.c | 2 | ||||
-rw-r--r-- | Modules/cjkcodecs/multibytecodec.h | 2 | ||||
-rw-r--r-- | Modules/gcmodule.c | 2 | ||||
-rw-r--r-- | Modules/grpmodule.c | 2 | ||||
-rw-r--r-- | Modules/parsermodule.c | 2 | ||||
-rw-r--r-- | Modules/sha512module.c | 2 | ||||
-rw-r--r-- | Modules/socketmodule.c | 2 |
26 files changed, 40 insertions, 40 deletions
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index 1d23973..97d7de4 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -539,7 +539,7 @@ deque_concat(dequeobject *deque, PyObject *other) if (rv == 0) { PyErr_Format(PyExc_TypeError, "can only concatenate deque (not \"%.200s\") to deque", - other->ob_type->tp_name); + Py_TYPE(other)->tp_name); } return NULL; } @@ -2395,7 +2395,7 @@ tuplegetter_descr_get(PyObject *self, PyObject *obj, PyObject *type) "descriptor for index '%zd' for tuple subclasses " "doesn't apply to '%s' object", index, - obj->ob_type->tp_name); + Py_TYPE(obj)->tp_name); return NULL; } diff --git a/Modules/_csv.c b/Modules/_csv.c index aaf3776..2d541bb 100644 --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -236,7 +236,7 @@ _set_char(const char *name, Py_UCS4 *target, PyObject *src, Py_UCS4 dflt) if (!PyUnicode_Check(src)) { PyErr_Format(PyExc_TypeError, "\"%s\" must be string, not %.200s", name, - src->ob_type->tp_name); + Py_TYPE(src)->tp_name); return -1; } len = PyUnicode_GetLength(src); @@ -807,7 +807,7 @@ Reader_iternext(ReaderObj *self) "iterator should return strings, " "not %.200s " "(did you open the file in text mode?)", - lineobj->ob_type->tp_name + Py_TYPE(lineobj)->tp_name ); Py_DECREF(lineobj); return NULL; @@ -1168,7 +1168,7 @@ csv_writerow(WriterObj *self, PyObject *seq) if (iter == NULL) return PyErr_Format(_csvstate_global->error_obj, "iterable expected, not %.200s", - seq->ob_type->tp_name); + Py_TYPE(seq)->tp_name); /* Join all fields in internal buffer. */ diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c index e0a50fd..f860e6e 100644 --- a/Modules/_ctypes/cfield.c +++ b/Modules/_ctypes/cfield.c @@ -274,7 +274,7 @@ static void PyCField_dealloc(PyObject *self) { PyCField_clear((CFieldObject *)self); - self->ob_type->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject * @@ -1175,7 +1175,7 @@ u_set(void *ptr, PyObject *value, Py_ssize_t size) if (!PyUnicode_Check(value)) { PyErr_Format(PyExc_TypeError, "unicode string expected instead of %s instance", - value->ob_type->tp_name); + Py_TYPE(value)->tp_name); return NULL; } else Py_INCREF(value); @@ -1234,7 +1234,7 @@ U_set(void *ptr, PyObject *value, Py_ssize_t length) if (!PyUnicode_Check(value)) { PyErr_Format(PyExc_TypeError, "unicode string expected instead of %s instance", - value->ob_type->tp_name); + Py_TYPE(value)->tp_name); return NULL; } @@ -1289,7 +1289,7 @@ s_set(void *ptr, PyObject *value, Py_ssize_t length) if(!PyBytes_Check(value)) { PyErr_Format(PyExc_TypeError, "expected bytes, %s found", - value->ob_type->tp_name); + Py_TYPE(value)->tp_name); return NULL; } @@ -1334,7 +1334,7 @@ z_set(void *ptr, PyObject *value, Py_ssize_t size) } PyErr_Format(PyExc_TypeError, "bytes or integer address expected instead of %s instance", - value->ob_type->tp_name); + Py_TYPE(value)->tp_name); return NULL; } @@ -1373,7 +1373,7 @@ Z_set(void *ptr, PyObject *value, Py_ssize_t size) if (!PyUnicode_Check(value)) { PyErr_Format(PyExc_TypeError, "unicode string or integer address expected instead of %s instance", - value->ob_type->tp_name); + Py_TYPE(value)->tp_name); return NULL; } @@ -1416,7 +1416,7 @@ BSTR_set(void *ptr, PyObject *value, Py_ssize_t size) } else if (!PyUnicode_Check(value)) { PyErr_Format(PyExc_TypeError, "unicode string expected instead of %s instance", - value->ob_type->tp_name); + Py_TYPE(value)->tp_name); return NULL; } diff --git a/Modules/_ctypes/ctypes.h b/Modules/_ctypes/ctypes.h index e58f852..351f996 100644 --- a/Modules/_ctypes/ctypes.h +++ b/Modules/_ctypes/ctypes.h @@ -102,7 +102,7 @@ typedef struct { } PyCFuncPtrObject; extern PyTypeObject PyCStgDict_Type; -#define PyCStgDict_CheckExact(v) ((v)->ob_type == &PyCStgDict_Type) +#define PyCStgDict_CheckExact(v) (Py_TYPE(v) == &PyCStgDict_Type) #define PyCStgDict_Check(v) PyObject_TypeCheck(v, &PyCStgDict_Type) extern int PyCStructUnionType_update_stgdict(PyObject *fields, PyObject *type, int isStruct); @@ -314,7 +314,7 @@ struct tagPyCArgObject { }; extern PyTypeObject PyCArg_Type; -#define PyCArg_CheckExact(v) ((v)->ob_type == &PyCArg_Type) +#define PyCArg_CheckExact(v) (Py_TYPE(v) == &PyCArg_Type) extern PyCArgObject *PyCArgObject_new(void); extern PyObject * diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c index 1d45ade..c8001a9 100644 --- a/Modules/_ctypes/stgdict.c +++ b/Modules/_ctypes/stgdict.c @@ -190,7 +190,7 @@ PyType_stgdict(PyObject *obj) StgDictObject * PyObject_stgdict(PyObject *self) { - PyTypeObject *type = self->ob_type; + PyTypeObject *type = Py_TYPE(self); if (!type->tp_dict || !PyCStgDict_CheckExact(type->tp_dict)) return NULL; return (StgDictObject *)type->tp_dict; diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index c2ce3a9..5b29000 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -2924,7 +2924,7 @@ _curses_getwin(PyObject *module, PyObject *file) if (!PyBytes_Check(data)) { PyErr_Format(PyExc_TypeError, "f.read() returned %.100s instead of bytes", - data->ob_type->tp_name); + Py_TYPE(data)->tp_name); Py_DECREF(data); goto error; } diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index 0b98cca..bc03c50 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -1810,7 +1810,7 @@ checked_divmod(PyObject *a, PyObject *b) if (!PyTuple_Check(result)) { PyErr_Format(PyExc_TypeError, "divmod() returned non-tuple (type %.200s)", - result->ob_type->tp_name); + Py_TYPE(result)->tp_name); Py_DECREF(result); return NULL; } diff --git a/Modules/_dbmmodule.c b/Modules/_dbmmodule.c index b317b57..072e977 100644 --- a/Modules/_dbmmodule.c +++ b/Modules/_dbmmodule.c @@ -255,7 +255,7 @@ dbm_contains(PyObject *self, PyObject *arg) else if (!PyBytes_Check(arg)) { PyErr_Format(PyExc_TypeError, "dbm key must be bytes or string, not %.100s", - arg->ob_type->tp_name); + Py_TYPE(arg)->tp_name); return -1; } else { diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c index e2ac198..75a8ddb 100644 --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -2584,7 +2584,7 @@ PyDecType_FromObjectExact(PyTypeObject *type, PyObject *v, PyObject *context) else { PyErr_Format(PyExc_TypeError, "conversion from %s to Decimal is not supported", - v->ob_type->tp_name); + Py_TYPE(v)->tp_name); return NULL; } } @@ -2633,7 +2633,7 @@ PyDec_FromObject(PyObject *v, PyObject *context) else { PyErr_Format(PyExc_TypeError, "conversion from %s to Decimal is not supported", - v->ob_type->tp_name); + Py_TYPE(v)->tp_name); return NULL; } } @@ -2696,7 +2696,7 @@ convert_op(int type_err, PyObject **conv, PyObject *v, PyObject *context) if (type_err) { PyErr_Format(PyExc_TypeError, "conversion from %s to Decimal is not supported", - v->ob_type->tp_name); + Py_TYPE(v)->tp_name); } else { Py_INCREF(Py_NotImplemented); diff --git a/Modules/_gdbmmodule.c b/Modules/_gdbmmodule.c index dd4a348..a815819 100644 --- a/Modules/_gdbmmodule.c +++ b/Modules/_gdbmmodule.c @@ -349,7 +349,7 @@ dbm_contains(PyObject *self, PyObject *arg) else if (!PyBytes_Check(arg)) { PyErr_Format(PyExc_TypeError, "gdbm key must be bytes or string, not %.100s", - arg->ob_type->tp_name); + Py_TYPE(arg)->tp_name); return -1; } else { diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c index 5932363..d609fa4 100644 --- a/Modules/_io/_iomodule.c +++ b/Modules/_io/_iomodule.c @@ -544,7 +544,7 @@ PyNumber_AsOff_t(PyObject *item, PyObject *err) /* Otherwise replace the error with caller's error object. */ PyErr_Format(err, "cannot fit '%.200s' into an offset-sized integer", - item->ob_type->tp_name); + Py_TYPE(item)->tp_name); } finish: diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index 5ebeb02..c4c56cb 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -1094,7 +1094,7 @@ _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer, PyErr_Format( PyExc_TypeError, "TextIOWrapper() argument 'errors' must be str or None, not %.50s", - errors->ob_type->tp_name); + Py_TYPE(errors)->tp_name); return -1; } else if (io_check_errors(errors)) { diff --git a/Modules/_json.c b/Modules/_json.c index 3e4fe79..a70043b 100644 --- a/Modules/_json.c +++ b/Modules/_json.c @@ -1617,7 +1617,7 @@ encoder_listencode_dict(PyEncoderObject *s, _PyAccu *acc, else { PyErr_Format(PyExc_TypeError, "keys must be str, int, float, bool or None, " - "not %.100s", key->ob_type->tp_name); + "not %.100s", Py_TYPE(key)->tp_name); goto bail; } diff --git a/Modules/_pickle.c b/Modules/_pickle.c index fc48d60..f67fb6a 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -1976,7 +1976,7 @@ fast_save_enter(PicklerObject *self, PyObject *obj) PyErr_Format(PyExc_ValueError, "fast mode: can't pickle cyclic objects " "including object type %.200s at %p", - obj->ob_type->tp_name, obj); + Py_TYPE(obj)->tp_name, obj); self->fast_nesting = -1; return 0; } diff --git a/Modules/_sqlite/microprotocols.c b/Modules/_sqlite/microprotocols.c index 59a5e22..bdcb174 100644 --- a/Modules/_sqlite/microprotocols.c +++ b/Modules/_sqlite/microprotocols.c @@ -84,7 +84,7 @@ pysqlite_microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt) way to get a quotable object to be its instance */ /* look for an adapter in the registry */ - key = Py_BuildValue("(OO)", (PyObject*)obj->ob_type, proto); + key = Py_BuildValue("(OO)", (PyObject*)Py_TYPE(obj), proto); if (!key) { return NULL; } diff --git a/Modules/_testbuffer.c b/Modules/_testbuffer.c index d7d3cc8..047e3d3 100644 --- a/Modules/_testbuffer.c +++ b/Modules/_testbuffer.c @@ -1854,7 +1854,7 @@ ndarray_subscript(NDArrayObject *self, PyObject *key) type_error: PyErr_Format(PyExc_TypeError, "cannot index memory using \"%.200s\"", - key->ob_type->tp_name); + Py_TYPE(key)->tp_name); err_occurred: Py_DECREF(nd); return NULL; diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index d8bf373..3bb1bf1 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -274,7 +274,7 @@ dict_hassplittable(PyObject *self, PyObject *arg) if (!PyDict_Check(arg)) { PyErr_Format(PyExc_TypeError, "dict_hassplittable() argument must be dict, not '%s'", - arg->ob_type->tp_name); + Py_TYPE(arg)->tp_name); return NULL; } @@ -2724,7 +2724,7 @@ test_thread_state(PyObject *self, PyObject *args) if (!PyCallable_Check(fn)) { PyErr_Format(PyExc_TypeError, "'%s' object is not callable", - fn->ob_type->tp_name); + Py_TYPE(fn)->tp_name); return NULL; } diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index 4f7d1b7..87bc7ae 100644 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -833,7 +833,7 @@ typedef struct { } PyTclObject; static PyObject *PyTclObject_Type; -#define PyTclObject_Check(v) ((v)->ob_type == (PyTypeObject *) PyTclObject_Type) +#define PyTclObject_Check(v) (Py_TYPE(v) == (PyTypeObject *) PyTclObject_Type) static PyObject * newPyTclObject(Tcl_Obj *arg) @@ -1734,7 +1734,7 @@ varname_converter(PyObject *in, void *_out) } PyErr_Format(PyExc_TypeError, "must be str, bytes or Tcl_Obj, not %.50s", - in->ob_type->tp_name); + Py_TYPE(in)->tp_name); return 0; } diff --git a/Modules/_xxsubinterpretersmodule.c b/Modules/_xxsubinterpretersmodule.c index fa20bc5..cc4f5d9 100644 --- a/Modules/_xxsubinterpretersmodule.c +++ b/Modules/_xxsubinterpretersmodule.c @@ -1428,7 +1428,7 @@ channel_id_converter(PyObject *arg, void *ptr) else { PyErr_Format(PyExc_TypeError, "channel ID must be an int, got %.100s", - arg->ob_type->tp_name); + Py_TYPE(arg)->tp_name); return 0; } *(int64_t *)ptr = cid; diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c index f24ec93..2dd63a9 100644 --- a/Modules/cjkcodecs/multibytecodec.c +++ b/Modules/cjkcodecs/multibytecodec.c @@ -1450,7 +1450,7 @@ mbstreamreader_iread(MultibyteStreamReaderObject *self, PyErr_Format(PyExc_TypeError, "stream function returned a " "non-bytes object (%.100s)", - cres->ob_type->tp_name); + Py_TYPE(cres)->tp_name); goto errorexit; } diff --git a/Modules/cjkcodecs/multibytecodec.h b/Modules/cjkcodecs/multibytecodec.h index 6d34534..94670ec 100644 --- a/Modules/cjkcodecs/multibytecodec.h +++ b/Modules/cjkcodecs/multibytecodec.h @@ -65,7 +65,7 @@ typedef struct { MultibyteCodec *codec; } MultibyteCodecObject; -#define MultibyteCodec_Check(op) ((op)->ob_type == &MultibyteCodec_Type) +#define MultibyteCodec_Check(op) (Py_TYPE(op) == &MultibyteCodec_Type) #define _MultibyteStatefulCodec_HEAD \ PyObject_HEAD \ diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c index 99a6c9e..7e9eae5 100644 --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -653,7 +653,7 @@ untrack_dicts(PyGC_Head *head) static int has_legacy_finalizer(PyObject *op) { - return op->ob_type->tp_del != NULL; + return Py_TYPE(op)->tp_del != NULL; } /* Move the objects in unreachable with tp_del slots into `finalizers`. diff --git a/Modules/grpmodule.c b/Modules/grpmodule.c index 81f969c..0e2801f 100644 --- a/Modules/grpmodule.c +++ b/Modules/grpmodule.c @@ -116,7 +116,7 @@ grp_getgrgid_impl(PyObject *module, PyObject *id) PyErr_Clear(); if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, "group id must be int, not %.200", - id->ob_type->tp_name) < 0) { + Py_TYPE(id)->tp_name) < 0) { return NULL; } py_int_id = PyNumber_Long(id); diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c index ef63ca9..f00329b 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) ((v)->ob_type == &PyST_Type) +#define PyST_Object_Check(v) (Py_TYPE(v) == &PyST_Type) static int parser_compare_nodes(node *left, node *right) diff --git a/Modules/sha512module.c b/Modules/sha512module.c index df4f9d2..4045698 100644 --- a/Modules/sha512module.c +++ b/Modules/sha512module.c @@ -478,7 +478,7 @@ SHA512Type_copy_impl(SHAobject *self) { SHAobject *newobj; - if (((PyObject*)self)->ob_type == &SHA512type) { + if (Py_TYPE((PyObject*)self) == &SHA512type) { if ( (newobj = newSHA512object())==NULL) return NULL; } else { diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index d42fa7c..e54f7a9 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -1670,7 +1670,7 @@ idna_converter(PyObject *obj, struct maybe_idna *data) } else { PyErr_Format(PyExc_TypeError, "str, bytes or bytearray expected, not %s", - obj->ob_type->tp_name); + Py_TYPE(obj)->tp_name); return 0; } if (strlen(data->buf) != len) { |