[Python-checkins] cpython (3.2): Silence a -Wformat-extra-argument warning when compiling.

gregory.p.smith python-checkins at python.org
Sat Feb 2 01:15:57 CET 2013


http://hg.python.org/cpython/rev/11047da3e5f6
changeset:   81894:11047da3e5f6
branch:      3.2
parent:      81890:e8a1b5757067
user:        Gregory P. Smith <greg at krypto.org>
date:        Fri Feb 01 16:14:00 2013 -0800
summary:
  Silence a -Wformat-extra-argument warning when compiling.

files:
  Objects/weakrefobject.c |  22 +++++++++++++++-------
  1 files changed, 15 insertions(+), 7 deletions(-)


diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c
--- a/Objects/weakrefobject.c
+++ b/Objects/weakrefobject.c
@@ -167,13 +167,21 @@
                 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 != NULL) {
+            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);

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list