summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-10-26 00:12:34 (GMT)
committerGitHub <noreply@github.com>2018-10-26 00:12:34 (GMT)
commit3ec9af75f6825a32f369ee182a388c365db241b6 (patch)
tree24c62eb4ca7b34034abb7eb5b1a0eff083f41b99 /Objects/object.c
parentc89a93271447ec65e83a1dc7605e62dbf272cafd (diff)
downloadcpython-3ec9af75f6825a32f369ee182a388c365db241b6.zip
cpython-3ec9af75f6825a32f369ee182a388c365db241b6.tar.gz
cpython-3ec9af75f6825a32f369ee182a388c365db241b6.tar.bz2
bpo-9263: _Py_NegativeRefcount() use _PyObject_AssertFailed() (GH-10109)
_Py_NegativeRefcount() now uses _PyObject_AssertFailed() to dump the object to help debugging.
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 2252f98..d6f27ff 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -205,13 +205,9 @@ void dec_count(PyTypeObject *tp)
void
_Py_NegativeRefcount(const char *filename, int lineno, PyObject *op)
{
- char buf[300];
-
- PyOS_snprintf(buf, sizeof(buf),
- "%s:%i object at %p has negative ref count "
- "%" PY_FORMAT_SIZE_T "d",
- filename, lineno, op, op->ob_refcnt);
- Py_FatalError(buf);
+ _PyObject_AssertFailed(op, "object has negative ref count",
+ "op->ob_refcnt >= 0",
+ filename, lineno, __func__);
}
#endif /* Py_REF_DEBUG */
@@ -356,13 +352,14 @@ PyObject_Print(PyObject *op, FILE *fp, int flags)
Py_END_ALLOW_THREADS
}
else {
- if (op->ob_refcnt <= 0)
+ if (op->ob_refcnt <= 0) {
/* XXX(twouters) cast refcount to long until %zd is
universally available */
Py_BEGIN_ALLOW_THREADS
fprintf(fp, "<refcnt %ld at %p>",
(long)op->ob_refcnt, op);
Py_END_ALLOW_THREADS
+ }
else {
PyObject *s;
if (flags & Py_PRINT_RAW)