Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c16fcdf

Browse files
committed
Make the PyXXX_Check() macros for the numeric types inheritance-aware.
1 parent c51395d commit c16fcdf

4 files changed

Lines changed: 4 additions & 4 deletions

File tree

Include/complexobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ typedef struct {
4242

4343
extern DL_IMPORT(PyTypeObject) PyComplex_Type;
4444

45-
#define PyComplex_Check(op) ((op)->ob_type == &PyComplex_Type)
45+
#define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type)
4646

4747
extern DL_IMPORT(PyObject *) PyComplex_FromCComplex(Py_complex);
4848
extern DL_IMPORT(PyObject *) PyComplex_FromDoubles(double real, double imag);

Include/floatobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ typedef struct {
1818

1919
extern DL_IMPORT(PyTypeObject) PyFloat_Type;
2020

21-
#define PyFloat_Check(op) ((op)->ob_type == &PyFloat_Type)
21+
#define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type)
2222

2323
/* Return Python float from string PyObject. Second argument ignored on
2424
input, and, if non-NULL, NULL is stored into *junk (this tried to serve a

Include/intobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ typedef struct {
2727

2828
extern DL_IMPORT(PyTypeObject) PyInt_Type;
2929

30-
#define PyInt_Check(op) ((op)->ob_type == &PyInt_Type)
30+
#define PyInt_Check(op) PyObject_TypeCheck(op, &PyInt_Type)
3131

3232
extern DL_IMPORT(PyObject *) PyInt_FromString(char*, char**, int);
3333
#ifdef Py_USING_UNICODE

Include/longobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ typedef struct _longobject PyLongObject; /* Revealed in longintrepr.h */
1111

1212
extern DL_IMPORT(PyTypeObject) PyLong_Type;
1313

14-
#define PyLong_Check(op) ((op)->ob_type == &PyLong_Type)
14+
#define PyLong_Check(op) PyObject_TypeCheck(op, &PyLong_Type)
1515

1616
extern DL_IMPORT(PyObject *) PyLong_FromLong(long);
1717
extern DL_IMPORT(PyObject *) PyLong_FromUnsignedLong(unsigned long);

0 commit comments

Comments
 (0)