Terry J. Reedy <[email protected]> added the comment:
With 3.2 on WinXP, I get no error report in interactive mode,
with either IDLE or plain interpreter, nor from 'python file' in Command Prompt
window. But now with the print added to what I ran before, I see no print
output, and I see that IDLE is restarting after executing the code, so
something *is* wrong. Further experiments with other print statements in
various places show that 'str(foo)' is the specific culprit.
Appears to act same on 3.1 for me.
Patch is to this code (from 3.2, presume same otherwise):
==============================
static PyObject *
object_str(PyObject *self)
{
unaryfunc f;
f = Py_TYPE(self)->tp_repr;
if (f == NULL)
f = object_repr;
return f(self);
}
=============================
Patch prevent infinite recursion if f == object_str.
Whether or not this fixes issue ('should' is a bit vague, confirmation is
needed) this seems like a good idea.
To be applied, patch should have a new testcase that fails without the patch
and passes with it applied.
----
def test_NoCrashIfStrIsRepr(self)
'see issue 11603'
class Foo(object): # delete object for 3.x
pass
Foo.__repr__ = Foo.__str__
foo = Foo()
s = str(foo)
----
would be a start. I so not know if any AssertX is needed since just finishing
would be a success. However, I also do not know where to put it as there is no
test_object or test_typeobject file that I see.
----------
nosy: +barry, terry.reedy
stage: -> test needed
versions: +Python 3.1, Python 3.3
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue11603>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com