Make generator repr consistent with function and code object repr.

This commit is contained in:
Georg Brandl 2008-05-16 09:34:48 +00:00
parent a8eaf8faf3
commit 5ffad6646e
3 changed files with 3 additions and 3 deletions

View File

@ -927,7 +927,7 @@ Test the __name__ attribute and the repr()
>>> g.__name__
'f'
>>> repr(g) # doctest: +ELLIPSIS
'<f generator object at ...>'
'<generator object f at ...>'
"""
# conjoin is a simple backtracking generator, named in honor of Icon's

View File

@ -92,7 +92,7 @@ Verify that parenthesis are required when used as a keyword argument value
Verify that parenthesis are required when used as a keyword argument value
>>> dict(a = (i for i in xrange(10))) #doctest: +ELLIPSIS
{'a': <<genexpr> generator object at ...>}
{'a': <generator object <genexpr> at ...>}
Verify early binding for the outermost for-expression

View File

@ -288,7 +288,7 @@ gen_repr(PyGenObject *gen)
code_name = PyString_AsString(((PyCodeObject *)gen->gi_code)->co_name);
if (code_name == NULL)
return NULL;
return PyString_FromFormat("<%.200s generator object at %p>",
return PyString_FromFormat("<generator object %.200s at %p>",
code_name, gen);
}