[Python-checkins] cpython: Use GetAttrId directly. Proposed by Amaury.

martin.v.loewis python-checkins at python.org
Thu Oct 13 20:04:06 CEST 2011


http://hg.python.org/cpython/rev/c060261a65b8
changeset:   72913:c060261a65b8
user:        Martin v. Löwis <martin at v.loewis.de>
date:        Thu Oct 13 20:03:57 2011 +0200
summary:
  Use GetAttrId directly. Proposed by Amaury.

files:
  Objects/typeobject.c |  9 +--------
  1 files changed, 1 insertions(+), 8 deletions(-)


diff --git a/Objects/typeobject.c b/Objects/typeobject.c
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -6308,16 +6308,9 @@
     }
     else {
         /* Try the slow way */
-        PyObject *class_str = NULL;
         PyObject *class_attr;
 
-        class_str = _PyUnicode_FromId(&PyId___class__);
-        if (class_str == NULL)
-            return NULL;
-
-        class_attr = PyObject_GetAttr(obj, class_str);
-        Py_DECREF(class_str);
-
+        class_attr = _PyObject_GetAttrId(obj, &PyId___class__);
         if (class_attr != NULL &&
             PyType_Check(class_attr) &&
             (PyTypeObject *)class_attr != Py_TYPE(obj))

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


More information about the Python-checkins mailing list