diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-05-08 03:06:00 +0000 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-05-08 03:06:00 +0000 |
commit | 6e4bf3715cac9053b28d8c00dd3528cdf1a4b130 (patch) | |
tree | 059ba4c3af25556309952025719664531bfe33cf /Objects/object.c | |
parent | 448bb8ec9a8225da2000f6e38953265d1e4684cf (diff) | |
download | cpython-6e4bf3715cac9053b28d8c00dd3528cdf1a4b130.tar.gz |
add _PyObject_LookupSpecial to handle fetching special method lookup
Diffstat (limited to 'Objects/object.c')
-rw-r--r-- | Objects/object.c | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/Objects/object.c b/Objects/object.c index 6254dfa0e5..3a7619324d 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); } } |