]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
fix strobject() behavior
authorGuido van Rossum <guido@python.org>
Tue, 17 Jan 1995 16:35:13 +0000 (16:35 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 17 Jan 1995 16:35:13 +0000 (16:35 +0000)
Objects/object.c

index be3cce7e809909a3a94d9783733c536bf94b3ada..63c55ce2ad726e55de5ef00f871e8502a26375c7 100644 (file)
@@ -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);
                }