File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -655,13 +655,21 @@ instance_repr(inst)
655655 if (func == NULL ) {
656656 char buf [140 ];
657657 PyObject * classname = inst -> in_class -> cl_name ;
658+ PyObject * mod = PyDict_GetItemString (
659+ inst -> in_class -> cl_dict , "__module__" );
658660 char * cname ;
659661 if (classname != NULL && PyString_Check (classname ))
660662 cname = PyString_AsString (classname );
661663 else
662664 cname = "?" ;
663665 PyErr_Clear ();
664- sprintf (buf , "<%.100s instance at %lx>" , cname , (long )inst );
666+ if (mod == NULL || !PyString_Check (mod ))
667+ sprintf (buf , "<?.%.100s instance at %lx>" ,
668+ cname , (long )inst );
669+ else
670+ sprintf (buf , "<%.50s.%.50s instance at %lx>" ,
671+ PyString_AsString (mod ),
672+ cname , (long )inst );
665673 return PyString_FromString (buf );
666674 }
667675 res = PyEval_CallObject (func , (PyObject * )NULL );
You can’t perform that action at this time.
0 commit comments