Commit dea6ef9b authored by Guido van Rossum's avatar Guido van Rossum

Replace a few places where X->ob_type was compared to &PyXXX_Type with

calls to PyXXX_CheckExact(X).
parent ae01046f
...@@ -775,7 +775,7 @@ PyFloat_Fini(void) ...@@ -775,7 +775,7 @@ PyFloat_Fini(void)
for (i = 0, p = &list->objects[0]; for (i = 0, p = &list->objects[0];
i < N_FLOATOBJECTS; i < N_FLOATOBJECTS;
i++, p++) { i++, p++) {
if (p->ob_type == &PyFloat_Type && p->ob_refcnt != 0) if (PyFloat_CheckExact(p) && p->ob_refcnt != 0)
frem++; frem++;
} }
next = list->next; next = list->next;
...@@ -785,7 +785,7 @@ PyFloat_Fini(void) ...@@ -785,7 +785,7 @@ PyFloat_Fini(void)
for (i = 0, p = &list->objects[0]; for (i = 0, p = &list->objects[0];
i < N_FLOATOBJECTS; i < N_FLOATOBJECTS;
i++, p++) { i++, p++) {
if (p->ob_type != &PyFloat_Type || if (!PyFloat_CheckExact(p) ||
p->ob_refcnt == 0) { p->ob_refcnt == 0) {
p->ob_type = (struct _typeobject *) p->ob_type = (struct _typeobject *)
free_list; free_list;
...@@ -818,7 +818,7 @@ PyFloat_Fini(void) ...@@ -818,7 +818,7 @@ PyFloat_Fini(void)
for (i = 0, p = &list->objects[0]; for (i = 0, p = &list->objects[0];
i < N_FLOATOBJECTS; i < N_FLOATOBJECTS;
i++, p++) { i++, p++) {
if (p->ob_type == &PyFloat_Type && if (PyFloat_CheckExact(p) &&
p->ob_refcnt != 0) { p->ob_refcnt != 0) {
char buf[100]; char buf[100];
PyFloat_AsString(buf, p); PyFloat_AsString(buf, p);
......
...@@ -134,7 +134,7 @@ PyInt_FromLong(long ival) ...@@ -134,7 +134,7 @@ PyInt_FromLong(long ival)
static void static void
int_dealloc(PyIntObject *v) int_dealloc(PyIntObject *v)
{ {
if (v->ob_type == &PyInt_Type) { if (PyInt_CheckExact(v)) {
v->ob_type = (struct _typeobject *)free_list; v->ob_type = (struct _typeobject *)free_list;
free_list = v; free_list = v;
} }
...@@ -999,7 +999,7 @@ PyInt_Fini(void) ...@@ -999,7 +999,7 @@ PyInt_Fini(void)
for (i = 0, p = &list->objects[0]; for (i = 0, p = &list->objects[0];
i < N_INTOBJECTS; i < N_INTOBJECTS;
i++, p++) { i++, p++) {
if (p->ob_type == &PyInt_Type && p->ob_refcnt != 0) if (PyInt_CheckExact(p) && p->ob_refcnt != 0)
irem++; irem++;
} }
next = list->next; next = list->next;
...@@ -1009,7 +1009,7 @@ PyInt_Fini(void) ...@@ -1009,7 +1009,7 @@ PyInt_Fini(void)
for (i = 0, p = &list->objects[0]; for (i = 0, p = &list->objects[0];
i < N_INTOBJECTS; i < N_INTOBJECTS;
i++, p++) { i++, p++) {
if (p->ob_type != &PyInt_Type || if (!PyInt_CheckExact(p) ||
p->ob_refcnt == 0) { p->ob_refcnt == 0) {
p->ob_type = (struct _typeobject *) p->ob_type = (struct _typeobject *)
free_list; free_list;
...@@ -1052,7 +1052,7 @@ PyInt_Fini(void) ...@@ -1052,7 +1052,7 @@ PyInt_Fini(void)
for (i = 0, p = &list->objects[0]; for (i = 0, p = &list->objects[0];
i < N_INTOBJECTS; i < N_INTOBJECTS;
i++, p++) { i++, p++) {
if (p->ob_type == &PyInt_Type && p->ob_refcnt != 0) if (PyInt_CheckExact(p) && p->ob_refcnt != 0)
fprintf(stderr, fprintf(stderr,
"# <int at %p, refcnt=%d, val=%ld>\n", "# <int at %p, refcnt=%d, val=%ld>\n",
p, p->ob_refcnt, p->ob_ival); p, p->ob_refcnt, p->ob_ival);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment