summaryrefslogtreecommitdiffstats
path: root/Objects/weakrefobject.c
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2011-02-22 20:15:44 (GMT)
committerBrett Cannon <bcannon@gmail.com>2011-02-22 20:15:44 (GMT)
commitb94767ff44edf5d461d7cb1c8eb5160f83886358 (patch)
treeb43b482e765b0383b3326779f6815e72b2bacccb /Objects/weakrefobject.c
parent79da6b7075a3d51ae042e77a2afca827e7bce435 (diff)
downloadcpython-b94767ff44edf5d461d7cb1c8eb5160f83886358.zip
cpython-b94767ff44edf5d461d7cb1c8eb5160f83886358.tar.gz
cpython-b94767ff44edf5d461d7cb1c8eb5160f83886358.tar.bz2
Issue #8914: fix various warnings from the Clang static analyzer v254.
Diffstat (limited to 'Objects/weakrefobject.c')
-rw-r--r--Objects/weakrefobject.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c
index 13323cf..dfaa1b9 100644
--- a/Objects/weakrefobject.c
+++ b/Objects/weakrefobject.c
@@ -168,13 +168,20 @@ weakref_repr(PyWeakReference *self)
PyErr_Clear();
else if (PyUnicode_Check(nameobj))
name = _PyUnicode_AsString(nameobj);
- PyOS_snprintf(buffer, sizeof(buffer),
- name ? "<weakref at %p; to '%.50s' at %p (%s)>"
- : "<weakref at %p; to '%.50s' at %p>",
- self,
- Py_TYPE(PyWeakref_GET_OBJECT(self))->tp_name,
- PyWeakref_GET_OBJECT(self),
- name);
+ if (name)
+ PyOS_snprintf(buffer, sizeof(buffer),
+ "<weakref at %p; to '%.50s' at %p (%s)>",
+ self,
+ Py_TYPE(PyWeakref_GET_OBJECT(self))->tp_name,
+ PyWeakref_GET_OBJECT(self),
+ name);
+ else
+ PyOS_snprintf(buffer, sizeof(buffer),
+ "<weakref at %p; to '%.50s' at %p>",
+ self,
+ Py_TYPE(PyWeakref_GET_OBJECT(self))->tp_name,
+ PyWeakref_GET_OBJECT(self));
+
Py_XDECREF(nameobj);
}
return PyUnicode_FromString(buffer);