Message131374
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. |
|
Date |
User |
Action |
Args |
2011-03-19 00:41:50 | terry.reedy | set | recipients:
+ terry.reedy, barry, aerojockey, Trundle |
2011-03-19 00:41:50 | terry.reedy | set | messageid: <1300495310.36.0.352191959863.issue11603@psf.upfronthosting.co.za> |
2011-03-19 00:41:49 | terry.reedy | link | issue11603 messages |
2011-03-19 00:41:49 | terry.reedy | create | |
|