[Python-checkins] bpo-39573: PyXXX_Check() macros use Py_IS_TYPE() (GH-18508)

Dong-hee Na webhook-mailer at python.org
Fri Feb 14 02:48:35 EST 2020


https://github.com/python/cpython/commit/d212c3c55d414203b0579e000d9f340f8cd11be7
commit: d212c3c55d414203b0579e000d9f340f8cd11be7
branch: master
author: Dong-hee Na <donghee.na92 at gmail.com>
committer: GitHub <noreply at github.com>
date: 2020-02-14T08:48:12+01:00
summary:

bpo-39573: PyXXX_Check() macros use Py_IS_TYPE() (GH-18508)

Update PyXXX_Check() macros in Include/ to use
the new Py_IS_TYPE function.

files:
M Include/classobject.h
M Include/picklebufobject.h

diff --git a/Include/classobject.h b/Include/classobject.h
index 8742720720550..1952f673b7d86 100644
--- a/Include/classobject.h
+++ b/Include/classobject.h
@@ -19,7 +19,7 @@ typedef struct {
 
 PyAPI_DATA(PyTypeObject) PyMethod_Type;
 
-#define PyMethod_Check(op) (Py_TYPE(op)== &PyMethod_Type)
+#define PyMethod_Check(op) Py_IS_TYPE(op, &PyMethod_Type)
 
 PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *);
 
@@ -40,7 +40,7 @@ typedef struct {
 
 PyAPI_DATA(PyTypeObject) PyInstanceMethod_Type;
 
-#define PyInstanceMethod_Check(op) (Py_TYPE(op) == &PyInstanceMethod_Type)
+#define PyInstanceMethod_Check(op) Py_IS_TYPE(op, &PyInstanceMethod_Type)
 
 PyAPI_FUNC(PyObject *) PyInstanceMethod_New(PyObject *);
 PyAPI_FUNC(PyObject *) PyInstanceMethod_Function(PyObject *);
diff --git a/Include/picklebufobject.h b/Include/picklebufobject.h
index f07e900bf26da..0df2561dceaea 100644
--- a/Include/picklebufobject.h
+++ b/Include/picklebufobject.h
@@ -12,7 +12,7 @@ extern "C" {
 
 PyAPI_DATA(PyTypeObject) PyPickleBuffer_Type;
 
-#define PyPickleBuffer_Check(op) (Py_TYPE(op) == &PyPickleBuffer_Type)
+#define PyPickleBuffer_Check(op) Py_IS_TYPE(op, &PyPickleBuffer_Type)
 
 /* Create a PickleBuffer redirecting to the given buffer-enabled object */
 PyAPI_FUNC(PyObject *) PyPickleBuffer_FromObject(PyObject *);



More information about the Python-checkins mailing list