summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-05-08 03:06:00 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-05-08 03:06:00 (GMT)
commit399e4c4f8f2570a342ac50e9500b12e86eb330a9 (patch)
tree46472e94ea46a4fbe8c3eebe3a30ef9fc529f6f8 /Objects/object.c
parentd846f1d4c21f4589966512f78a4a4d74f8399d6d (diff)
downloadcpython-399e4c4f8f2570a342ac50e9500b12e86eb330a9.zip
cpython-399e4c4f8f2570a342ac50e9500b12e86eb330a9.tar.gz
cpython-399e4c4f8f2570a342ac50e9500b12e86eb330a9.tar.bz2
add _PyObject_LookupSpecial to handle fetching special method lookup
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 6254dfa..3a76193 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -488,12 +488,6 @@ PyObject_Unicode(PyObject *v)
return v;
}
- /* Try the __unicode__ method */
- if (unicodestr == NULL) {
- unicodestr= PyString_InternFromString("__unicode__");
- if (unicodestr == NULL)
- return NULL;
- }
if (PyInstance_Check(v)) {
/* We're an instance of a classic class */
/* Try __unicode__ from the instance -- alas we have no type */
@@ -508,15 +502,12 @@ PyObject_Unicode(PyObject *v)
}
}
else {
- /* Not a classic class instance, try __unicode__ from type */
- /* _PyType_Lookup doesn't create a reference */
- func = _PyType_Lookup(Py_TYPE(v), unicodestr);
+ /* Not a classic class instance, try __unicode__. */
+ func = _PyObject_LookupSpecial(v, "__unicode__", &unicodestr);
if (func != NULL) {
unicode_method_found = 1;
res = PyObject_CallFunctionObjArgs(func, v, NULL);
- }
- else {
- PyErr_Clear();
+ Py_DECREF(func);
}
}