summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-07-10 12:40:38 +0200
committerGitHub <noreply@github.com>2020-07-10 12:40:38 +0200
commit8182cc2e68a3c6ea5d5342fed3f1c76b0521fbc1 (patch)
tree697757da0c635614b16aafc81c3ea1172a634a53
parentd878349bac6c154fbfeffe7d4b38e2ddb833f135 (diff)
downloadcpython-git-8182cc2e68a3c6ea5d5342fed3f1c76b0521fbc1.tar.gz
bpo-39573: Use the Py_TYPE() macro (GH-21433)
Replace obj->ob_type with Py_TYPE(obj).
-rw-r--r--Modules/_elementtree.c2
-rw-r--r--Objects/abstract.c4
-rw-r--r--Objects/genericaliasobject.c2
-rw-r--r--Objects/unicodeobject.c4
-rw-r--r--PC/_msi.c6
-rw-r--r--PC/winreg.c4
-rwxr-xr-xTools/scripts/combinerefs.py2
7 files changed, 12 insertions, 12 deletions
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 2c92a8aedb..85fdfa7e5e 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -2040,7 +2040,7 @@ element_attrib_setter(ElementObject *self, PyObject *value, void *closure)
if (!PyDict_Check(value)) {
PyErr_Format(PyExc_TypeError,
"attrib must be dict, not %.200s",
- value->ob_type->tp_name);
+ Py_TYPE(value)->tp_name);
return -1;
}
if (!self->extra) {
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 3494f33ce3..7bd72c9b5d 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -1382,7 +1382,7 @@ PyNumber_Long(PyObject *o)
if (!PyLong_Check(result)) {
PyErr_Format(PyExc_TypeError,
"__int__ returned non-int (type %.200s)",
- result->ob_type->tp_name);
+ Py_TYPE(result)->tp_name);
Py_DECREF(result);
return NULL;
}
@@ -1391,7 +1391,7 @@ PyNumber_Long(PyObject *o)
"__int__ returned non-int (type %.200s). "
"The ability to return an instance of a strict subclass of int "
"is deprecated, and may be removed in a future version of Python.",
- result->ob_type->tp_name)) {
+ Py_TYPE(result)->tp_name)) {
Py_DECREF(result);
return NULL;
}
diff --git a/Objects/genericaliasobject.c b/Objects/genericaliasobject.c
index 4d511a2390..87bd1ae5c1 100644
--- a/Objects/genericaliasobject.c
+++ b/Objects/genericaliasobject.c
@@ -20,7 +20,7 @@ ga_dealloc(PyObject *self)
Py_XDECREF(alias->origin);
Py_XDECREF(alias->args);
Py_XDECREF(alias->parameters);
- self->ob_type->tp_free(self);
+ Py_TYPE(self)->tp_free(self);
}
static int
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 809ed85895..648dd15ca0 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -3325,7 +3325,7 @@ _PyUnicode_WideCharString_Converter(PyObject *obj, void *ptr)
}
PyErr_Format(PyExc_TypeError,
"argument must be str, not %.50s",
- obj->ob_type->tp_name);
+ Py_TYPE(obj)->tp_name);
return 0;
}
@@ -3361,7 +3361,7 @@ _PyUnicode_WideCharString_Opt_Converter(PyObject *obj, void *ptr)
}
PyErr_Format(PyExc_TypeError,
"argument must be str or None, not %.50s",
- obj->ob_type->tp_name);
+ Py_TYPE(obj)->tp_name);
return 0;
}
diff --git a/PC/_msi.c b/PC/_msi.c
index f725c81620..504899d075 100644
--- a/PC/_msi.c
+++ b/PC/_msi.c
@@ -193,7 +193,7 @@ static FNFCIGETNEXTCABINET(cb_getnextcabinet)
if (!PyBytes_Check(result)) {
PyErr_Format(PyExc_TypeError,
"Incorrect return type %s from getnextcabinet",
- result->ob_type->tp_name);
+ Py_TYPE(result)->tp_name);
Py_DECREF(result);
return FALSE;
}
@@ -879,7 +879,7 @@ _msi_View_Execute(msiobj *self, PyObject *oparams)
MSIHANDLE params = 0;
if (oparams != Py_None) {
- if (oparams->ob_type != &record_Type) {
+ if (!Py_IS_TYPE(oparams, &record_Type)) {
PyErr_SetString(PyExc_TypeError, "Execute argument must be a record");
return NULL;
}
@@ -955,7 +955,7 @@ _msi_View_Modify_impl(msiobj *self, int kind, PyObject *data)
{
int status;
- if (data->ob_type != &record_Type) {
+ if (!Py_IS_TYPE(data, &record_Type)) {
PyErr_SetString(PyExc_TypeError, "Modify expects a record object");
return NULL;
}
diff --git a/PC/winreg.c b/PC/winreg.c
index 7c3b2f4be8..b2725b857d 100644
--- a/PC/winreg.c
+++ b/PC/winreg.c
@@ -112,7 +112,7 @@ typedef struct {
HKEY hkey;
} PyHKEYObject;
-#define PyHKEY_Check(op) ((op)->ob_type == &PyHKEY_Type)
+#define PyHKEY_Check(op) Py_IS_TYPE(op, &PyHKEY_Type)
static char *failMsg = "bad operand type";
@@ -693,7 +693,7 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize)
PyErr_Format(PyExc_TypeError,
"Objects of type '%s' can not "
"be used as binary registry values",
- value->ob_type->tp_name);
+ Py_TYPE(value)->tp_name);
return FALSE;
}
diff --git a/Tools/scripts/combinerefs.py b/Tools/scripts/combinerefs.py
index 49ccca7390..848bae5658 100755
--- a/Tools/scripts/combinerefs.py
+++ b/Tools/scripts/combinerefs.py
@@ -33,7 +33,7 @@ or
if the refcount changed.
-typename is object->ob_type->tp_name, extracted from the second PYTHONDUMPREFS
+typename is Py_TYPE(object)->tp_name, extracted from the second PYTHONDUMPREFS
output block.
repr is repr(object), extracted from the first PYTHONDUMPREFS output block.