]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-39573: Use the Py_TYPE() macro (GH-21433)
authorVictor Stinner <vstinner@python.org>
Fri, 10 Jul 2020 10:40:38 +0000 (12:40 +0200)
committerGitHub <noreply@github.com>
Fri, 10 Jul 2020 10:40:38 +0000 (12:40 +0200)
Replace obj->ob_type with Py_TYPE(obj).

Modules/_elementtree.c
Objects/abstract.c
Objects/genericaliasobject.c
Objects/unicodeobject.c
PC/_msi.c
PC/winreg.c
Tools/scripts/combinerefs.py

index 2c92a8aedb5a8841a9354defc38a9a97882888e1..85fdfa7e5ed42cfd7bef4e95b674d4b57ef8224f 100644 (file)
@@ -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) {
index 3494f33ce380ca0af4f271f1cbb346361b8d1730..7bd72c9b5dcc26985989a85fd5c5ff9bd85db56b 100644 (file)
@@ -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;
         }
index 4d511a239063ceb67f7c3296fad7d8c8eae2456e..87bd1ae5c1430b56ba6c0c5d04f3ac38b8785fe8 100644 (file)
@@ -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
index 809ed85895f86fe52e36ceb4d8304e0324d99494..648dd15ca09f58801aee00732267c03402988197 100644 (file)
@@ -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;
 }
 
index f725c816206e7251bca15a4f49e33e8134142e03..504899d0757b78cb22e68777c1abbf8f377d4823 100644 (file)
--- 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;
     }
index 7c3b2f4be85c963c48385c9dba3b97d7ce0ca6fc..b2725b857d0c2276b816fb0ddce6b11324c97e77 100644 (file)
@@ -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;
                 }
 
index 49ccca73909fc8f715b84c3e08df3cecaf9977b4..848bae5658ca3ab266df5e4ded7dbc3f0c94c862 100755 (executable)
@@ -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.