From 32b582b953f5859de325496df1da9731234b17fa Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 17 Jan 1995 16:35:13 +0000 Subject: fix strobject() behavior --- Objects/object.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Objects/object.c b/Objects/object.c index be3cce7..63c55ce 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -181,11 +181,13 @@ strobject(v) INCREF(v); return v; } + else if (v->ob_type->tp_str != NULL) + return (*v->ob_type->tp_str)(v); else { - object *func = getattr(v, "__str__"); + object *func; object *args; object *res; - if (func == NULL) { + if (!is_instanceobject(v) || (func = getattr(v, "__str__")) == NULL) { err_clear(); return reprobject(v); } -- cgit v0.12