mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Fix the baffler that Tim reported: sometimes the repr() of an object
looks like <X object at ...>, sometimes it says <X instance at ...>. Make this uniformly say <X object at ...>.
This commit is contained in:
parent
f244b2e47c
commit
ff0e6d6ef5
2 changed files with 4 additions and 4 deletions
|
@ -1193,7 +1193,7 @@ def specials():
|
||||||
verify(not c1 == c2)
|
verify(not c1 == c2)
|
||||||
# Note that the module name appears in str/repr, and that varies
|
# Note that the module name appears in str/repr, and that varies
|
||||||
# depending on whether this test is run standalone or from a framework.
|
# depending on whether this test is run standalone or from a framework.
|
||||||
verify(str(c1).find('C instance at ') >= 0)
|
verify(str(c1).find('C object at ') >= 0)
|
||||||
verify(str(c1) == repr(c1))
|
verify(str(c1) == repr(c1))
|
||||||
verify(-1 not in c1)
|
verify(-1 not in c1)
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
|
@ -1216,7 +1216,7 @@ def specials():
|
||||||
verify(not d1 == d2)
|
verify(not d1 == d2)
|
||||||
# Note that the module name appears in str/repr, and that varies
|
# Note that the module name appears in str/repr, and that varies
|
||||||
# depending on whether this test is run standalone or from a framework.
|
# depending on whether this test is run standalone or from a framework.
|
||||||
verify(str(d1).find('D instance at ') >= 0)
|
verify(str(d1).find('D object at ') >= 0)
|
||||||
verify(str(d1) == repr(d1))
|
verify(str(d1) == repr(d1))
|
||||||
verify(-1 not in d1)
|
verify(-1 not in d1)
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
|
|
|
@ -1157,12 +1157,12 @@ object_repr(PyObject *self)
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (mod != NULL && strcmp(PyString_AS_STRING(mod), "__builtin__"))
|
if (mod != NULL && strcmp(PyString_AS_STRING(mod), "__builtin__"))
|
||||||
rtn = PyString_FromFormat("<%s.%s instance at %p>",
|
rtn = PyString_FromFormat("<%s.%s object at %p>",
|
||||||
PyString_AS_STRING(mod),
|
PyString_AS_STRING(mod),
|
||||||
PyString_AS_STRING(name),
|
PyString_AS_STRING(name),
|
||||||
self);
|
self);
|
||||||
else
|
else
|
||||||
rtn = PyString_FromFormat("<%s instance at %p>",
|
rtn = PyString_FromFormat("<%s object at %p>",
|
||||||
type->tp_name, self);
|
type->tp_name, self);
|
||||||
Py_XDECREF(mod);
|
Py_XDECREF(mod);
|
||||||
Py_DECREF(name);
|
Py_DECREF(name);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue