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

Skip to content

Commit dea6ef9

Browse files
committed
Replace a few places where X->ob_type was compared to &PyXXX_Type with
calls to PyXXX_CheckExact(X).
1 parent ae01046 commit dea6ef9

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

Objects/floatobject.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ PyFloat_Fini(void)
775775
for (i = 0, p = &list->objects[0];
776776
i < N_FLOATOBJECTS;
777777
i++, p++) {
778-
if (p->ob_type == &PyFloat_Type && p->ob_refcnt != 0)
778+
if (PyFloat_CheckExact(p) && p->ob_refcnt != 0)
779779
frem++;
780780
}
781781
next = list->next;
@@ -785,7 +785,7 @@ PyFloat_Fini(void)
785785
for (i = 0, p = &list->objects[0];
786786
i < N_FLOATOBJECTS;
787787
i++, p++) {
788-
if (p->ob_type != &PyFloat_Type ||
788+
if (!PyFloat_CheckExact(p) ||
789789
p->ob_refcnt == 0) {
790790
p->ob_type = (struct _typeobject *)
791791
free_list;
@@ -818,7 +818,7 @@ PyFloat_Fini(void)
818818
for (i = 0, p = &list->objects[0];
819819
i < N_FLOATOBJECTS;
820820
i++, p++) {
821-
if (p->ob_type == &PyFloat_Type &&
821+
if (PyFloat_CheckExact(p) &&
822822
p->ob_refcnt != 0) {
823823
char buf[100];
824824
PyFloat_AsString(buf, p);

Objects/intobject.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ PyInt_FromLong(long ival)
134134
static void
135135
int_dealloc(PyIntObject *v)
136136
{
137-
if (v->ob_type == &PyInt_Type) {
137+
if (PyInt_CheckExact(v)) {
138138
v->ob_type = (struct _typeobject *)free_list;
139139
free_list = v;
140140
}
@@ -999,7 +999,7 @@ PyInt_Fini(void)
999999
for (i = 0, p = &list->objects[0];
10001000
i < N_INTOBJECTS;
10011001
i++, p++) {
1002-
if (p->ob_type == &PyInt_Type && p->ob_refcnt != 0)
1002+
if (PyInt_CheckExact(p) && p->ob_refcnt != 0)
10031003
irem++;
10041004
}
10051005
next = list->next;
@@ -1009,7 +1009,7 @@ PyInt_Fini(void)
10091009
for (i = 0, p = &list->objects[0];
10101010
i < N_INTOBJECTS;
10111011
i++, p++) {
1012-
if (p->ob_type != &PyInt_Type ||
1012+
if (!PyInt_CheckExact(p) ||
10131013
p->ob_refcnt == 0) {
10141014
p->ob_type = (struct _typeobject *)
10151015
free_list;
@@ -1052,7 +1052,7 @@ PyInt_Fini(void)
10521052
for (i = 0, p = &list->objects[0];
10531053
i < N_INTOBJECTS;
10541054
i++, p++) {
1055-
if (p->ob_type == &PyInt_Type && p->ob_refcnt != 0)
1055+
if (PyInt_CheckExact(p) && p->ob_refcnt != 0)
10561056
fprintf(stderr,
10571057
"# <int at %p, refcnt=%d, val=%ld>\n",
10581058
p, p->ob_refcnt, p->ob_ival);

0 commit comments

Comments
 (0)