summaryrefslogtreecommitdiffstats
path: root/Objects/classobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/classobject.c')
-rw-r--r--Objects/classobject.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c
index b67265b..b6052a0 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -655,13 +655,21 @@ instance_repr(inst)
if (func == NULL) {
char buf[140];
PyObject *classname = inst->in_class->cl_name;
+ PyObject *mod = PyDict_GetItemString(
+ inst->in_class->cl_dict, "__module__");
char *cname;
if (classname != NULL && PyString_Check(classname))
cname = PyString_AsString(classname);
else
cname = "?";
PyErr_Clear();
- sprintf(buf, "<%.100s instance at %lx>", cname, (long)inst);
+ if (mod == NULL || !PyString_Check(mod))
+ sprintf(buf, "<?.%.100s instance at %lx>",
+ cname, (long)inst);
+ else
+ sprintf(buf, "<%.50s.%.50s instance at %lx>",
+ PyString_AsString(mod),
+ cname, (long)inst);
return PyString_FromString(buf);
}
res = PyEval_CallObject(func, (PyObject *)NULL);