Commit 8b87a0b5 authored by Thomas Wouters's avatar Thomas Wouters

Use %ld and casts to long for refcount printing, in absense of a universally

available %zd format character. Mark with an XXX comment so we can fix this,
later.
parent 572a9f32
...@@ -1326,9 +1326,13 @@ PyFloat_Fini(void) ...@@ -1326,9 +1326,13 @@ PyFloat_Fini(void)
p->ob_refcnt != 0) { p->ob_refcnt != 0) {
char buf[100]; char buf[100];
PyFloat_AsString(buf, p); PyFloat_AsString(buf, p);
/* XXX(twouters) cast refcount to
long until %zd is universally
available
*/
fprintf(stderr, fprintf(stderr,
"# <float at %p, refcnt=%d, val=%s>\n", "# <float at %p, refcnt=%ld, val=%s>\n",
p, p->ob_refcnt, buf); p, (long)p->ob_refcnt, buf);
} }
} }
list = list->next; list = list->next;
......
...@@ -1220,9 +1220,14 @@ PyInt_Fini(void) ...@@ -1220,9 +1220,14 @@ PyInt_Fini(void)
i < N_INTOBJECTS; i < N_INTOBJECTS;
i++, p++) { i++, p++) {
if (PyInt_CheckExact(p) && p->ob_refcnt != 0) if (PyInt_CheckExact(p) && p->ob_refcnt != 0)
/* XXX(twouters) cast refcount to
long until %zd is universally
available
*/
fprintf(stderr, fprintf(stderr,
"# <int at %p, refcnt=%d, val=%ld>\n", "# <int at %p, refcnt=%ld, val=%ld>\n",
p, p->ob_refcnt, p->ob_ival); p, (long)p->ob_refcnt,
p->ob_ival);
} }
list = list->next; list = list->next;
} }
......
...@@ -138,9 +138,11 @@ _Py_NegativeRefcount(const char *fname, int lineno, PyObject *op) ...@@ -138,9 +138,11 @@ _Py_NegativeRefcount(const char *fname, int lineno, PyObject *op)
{ {
char buf[300]; char buf[300];
/* XXX(twouters) cast refcount to long until %zd is universally
available */
PyOS_snprintf(buf, sizeof(buf), PyOS_snprintf(buf, sizeof(buf),
"%s:%i object at %p has negative ref count %i", "%s:%i object at %p has negative ref count %ld",
fname, lineno, op, op->ob_refcnt); fname, lineno, op, (long)op->ob_refcnt);
Py_FatalError(buf); Py_FatalError(buf);
} }
...@@ -233,8 +235,10 @@ internal_print(PyObject *op, FILE *fp, int flags, int nesting) ...@@ -233,8 +235,10 @@ internal_print(PyObject *op, FILE *fp, int flags, int nesting)
} }
else { else {
if (op->ob_refcnt <= 0) if (op->ob_refcnt <= 0)
fprintf(fp, "<refcnt %u at %p>", /* XXX(twouters) cast refcount to long until %zd is
op->ob_refcnt, op); universally available */
fprintf(fp, "<refcnt %ld at %p>",
(long)op->ob_refcnt, op);
else if (op->ob_type->tp_print == NULL) { else if (op->ob_type->tp_print == NULL) {
PyObject *s; PyObject *s;
if (flags & Py_PRINT_RAW) if (flags & Py_PRINT_RAW)
...@@ -277,12 +281,14 @@ void _PyObject_Dump(PyObject* op) ...@@ -277,12 +281,14 @@ void _PyObject_Dump(PyObject* op)
else { else {
fprintf(stderr, "object : "); fprintf(stderr, "object : ");
(void)PyObject_Print(op, stderr, 0); (void)PyObject_Print(op, stderr, 0);
/* XXX(twouters) cast refcount to long until %zd is
universally available */
fprintf(stderr, "\n" fprintf(stderr, "\n"
"type : %s\n" "type : %s\n"
"refcount: %d\n" "refcount: %ld\n"
"address : %p\n", "address : %p\n",
op->ob_type==NULL ? "NULL" : op->ob_type->tp_name, op->ob_type==NULL ? "NULL" : op->ob_type->tp_name,
op->ob_refcnt, (long)op->ob_refcnt,
op); op);
} }
} }
...@@ -1893,7 +1899,9 @@ _Py_PrintReferences(FILE *fp) ...@@ -1893,7 +1899,9 @@ _Py_PrintReferences(FILE *fp)
PyObject *op; PyObject *op;
fprintf(fp, "Remaining objects:\n"); fprintf(fp, "Remaining objects:\n");
for (op = refchain._ob_next; op != &refchain; op = op->_ob_next) { for (op = refchain._ob_next; op != &refchain; op = op->_ob_next) {
fprintf(fp, "%p [%d] ", op, op->ob_refcnt); /* XXX(twouters) cast refcount to long until %zd is
universally available */
fprintf(fp, "%p [%ld] ", op, (long)op->ob_refcnt);
if (PyObject_Print(op, fp, 0) != 0) if (PyObject_Print(op, fp, 0) != 0)
PyErr_Clear(); PyErr_Clear();
putc('\n', fp); putc('\n', fp);
...@@ -1909,7 +1917,9 @@ _Py_PrintReferenceAddresses(FILE *fp) ...@@ -1909,7 +1917,9 @@ _Py_PrintReferenceAddresses(FILE *fp)
PyObject *op; PyObject *op;
fprintf(fp, "Remaining object addresses:\n"); fprintf(fp, "Remaining object addresses:\n");
for (op = refchain._ob_next; op != &refchain; op = op->_ob_next) for (op = refchain._ob_next; op != &refchain; op = op->_ob_next)
fprintf(fp, "%p [%d] %s\n", op, op->ob_refcnt, /* XXX(twouters) cast refcount to long until %zd is
universally available */
fprintf(fp, "%p [%ld] %s\n", op, (long)op->ob_refcnt,
op->ob_type->tp_name); op->ob_type->tp_name);
} }
......
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