bpo-39573: Use the Py_TYPE() macro (GH-21433) · python/cpython@8182cc2 (original) (raw)
7 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2040,7 +2040,7 @@ element_attrib_setter(ElementObject *self, PyObject *value, void *closure) | ||
2040 | 2040 | if (!PyDict_Check(value)) { |
2041 | 2041 | PyErr_Format(PyExc_TypeError, |
2042 | 2042 | "attrib must be dict, not %.200s", |
2043 | -value->ob_type->tp_name); | |
2043 | +Py_TYPE(value)->tp_name); | |
2044 | 2044 | return -1; |
2045 | 2045 | } |
2046 | 2046 | if (!self->extra) { |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1382,7 +1382,7 @@ PyNumber_Long(PyObject *o) | ||
1382 | 1382 | if (!PyLong_Check(result)) { |
1383 | 1383 | PyErr_Format(PyExc_TypeError, |
1384 | 1384 | "__int__ returned non-int (type %.200s)", |
1385 | -result->ob_type->tp_name); | |
1385 | +Py_TYPE(result)->tp_name); | |
1386 | 1386 | Py_DECREF(result); |
1387 | 1387 | return NULL; |
1388 | 1388 | } |
@@ -1391,7 +1391,7 @@ PyNumber_Long(PyObject *o) | ||
1391 | 1391 | "__int__ returned non-int (type %.200s). " |
1392 | 1392 | "The ability to return an instance of a strict subclass of int " |
1393 | 1393 | "is deprecated, and may be removed in a future version of Python.", |
1394 | -result->ob_type->tp_name)) { | |
1394 | +Py_TYPE(result)->tp_name)) { | |
1395 | 1395 | Py_DECREF(result); |
1396 | 1396 | return NULL; |
1397 | 1397 | } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -20,7 +20,7 @@ ga_dealloc(PyObject *self) | ||
20 | 20 | Py_XDECREF(alias->origin); |
21 | 21 | Py_XDECREF(alias->args); |
22 | 22 | Py_XDECREF(alias->parameters); |
23 | -self->ob_type->tp_free(self); | |
23 | +Py_TYPE(self)->tp_free(self); | |
24 | 24 | } |
25 | 25 | |
26 | 26 | static int |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -3325,7 +3325,7 @@ _PyUnicode_WideCharString_Converter(PyObject *obj, void *ptr) | ||
3325 | 3325 | } |
3326 | 3326 | PyErr_Format(PyExc_TypeError, |
3327 | 3327 | "argument must be str, not %.50s", |
3328 | -obj->ob_type->tp_name); | |
3328 | +Py_TYPE(obj)->tp_name); | |
3329 | 3329 | return 0; |
3330 | 3330 | } |
3331 | 3331 | |
@@ -3361,7 +3361,7 @@ _PyUnicode_WideCharString_Opt_Converter(PyObject *obj, void *ptr) | ||
3361 | 3361 | } |
3362 | 3362 | PyErr_Format(PyExc_TypeError, |
3363 | 3363 | "argument must be str or None, not %.50s", |
3364 | -obj->ob_type->tp_name); | |
3364 | +Py_TYPE(obj)->tp_name); | |
3365 | 3365 | return 0; |
3366 | 3366 | } |
3367 | 3367 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -193,7 +193,7 @@ static FNFCIGETNEXTCABINET(cb_getnextcabinet) | ||
193 | 193 | if (!PyBytes_Check(result)) { |
194 | 194 | PyErr_Format(PyExc_TypeError, |
195 | 195 | "Incorrect return type %s from getnextcabinet", |
196 | -result->ob_type->tp_name); | |
196 | +Py_TYPE(result)->tp_name); | |
197 | 197 | Py_DECREF(result); |
198 | 198 | return FALSE; |
199 | 199 | } |
@@ -879,7 +879,7 @@ _msi_View_Execute(msiobj *self, PyObject *oparams) | ||
879 | 879 | MSIHANDLE params = 0; |
880 | 880 | |
881 | 881 | if (oparams != Py_None) { |
882 | -if (oparams->ob_type != &record_Type) { | |
882 | +if (!Py_IS_TYPE(oparams, &record_Type)) { | |
883 | 883 | PyErr_SetString(PyExc_TypeError, "Execute argument must be a record"); |
884 | 884 | return NULL; |
885 | 885 | } |
@@ -955,7 +955,7 @@ _msi_View_Modify_impl(msiobj *self, int kind, PyObject *data) | ||
955 | 955 | { |
956 | 956 | int status; |
957 | 957 | |
958 | -if (data->ob_type != &record_Type) { | |
958 | +if (!Py_IS_TYPE(data, &record_Type)) { | |
959 | 959 | PyErr_SetString(PyExc_TypeError, "Modify expects a record object"); |
960 | 960 | return NULL; |
961 | 961 | } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -112,7 +112,7 @@ typedef struct { | ||
112 | 112 | HKEY hkey; |
113 | 113 | } PyHKEYObject; |
114 | 114 | |
115 | -#define PyHKEY_Check(op) ((op)->ob_type == &PyHKEY_Type) | |
115 | +#define PyHKEY_Check(op) Py_IS_TYPE(op, &PyHKEY_Type) | |
116 | 116 | |
117 | 117 | static char *failMsg = "bad operand type"; |
118 | 118 | |
@@ -693,7 +693,7 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize) | ||
693 | 693 | PyErr_Format(PyExc_TypeError, |
694 | 694 | "Objects of type '%s' can not " |
695 | 695 | "be used as binary registry values", |
696 | -value->ob_type->tp_name); | |
696 | +Py_TYPE(value)->tp_name); | |
697 | 697 | return FALSE; |
698 | 698 | } |
699 | 699 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -33,7 +33,7 @@ | ||
33 | 33 | |
34 | 34 | if the refcount changed. |
35 | 35 | |
36 | -typename is object->ob_type->tp_name, extracted from the second PYTHONDUMPREFS | |
36 | +typename is Py_TYPE(object)->tp_name, extracted from the second PYTHONDUMPREFS | |
37 | 37 | output block. |
38 | 38 | |
39 | 39 | repr is repr(object), extracted from the first PYTHONDUMPREFS output block. |