Skip to content

bpo-39573: Use the Py_TYPE() macro #21433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Modules/_elementtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions Objects/abstract.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion Objects/genericaliasobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions PC/_msi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions PC/winreg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion Tools/scripts/combinerefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

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.
Expand Down