Abend with cls.__repr__ = cls.__str__ on Windows.
Duncan Booth
duncan.booth at invalid.invalid
Fri Mar 18 05:18:24 EDT 2011
Terry Reedy <tjreedy at udel.edu> wrote:
> On 3/17/2011 10:00 PM, Terry Reedy wrote:
>> On 3/17/2011 8:24 PM, J Peyret wrote:
>>> This gives a particularly nasty abend in Windows - "Python.exe has
>>> stopped working", rather than a regular exception stack error. I've
>>> fixed it, after I figured out the cause, which took a while, but
maybe
>>> someone will benefit from this.
>>>
>>> Python 2.6.5 on Windows 7.
>>>
>>> class Foo(object):
>>> pass
>>>
>>> Foo.__repr__ = Foo.__str__ # this will cause an abend.
>>
>> 2.7.1 and 3.2.0 on winxp, no problem, interactive intepreter or IDLE
>> shell. Upgrade?
>
> To be clear, the above, with added indent, but with extra fluff
(fixes)
> removed, is exactly what I ran. If you got error with anything else,
> please say so. Described behavior for legal code is a bug. However,
> unless a security issue, it would not be fixed for 2.6.
>
On Windows, I can replicate this with Python 2.7, Python 3.1.2, and
Python 3.2. Here's the exact script (I had to change the print to be
compatible with Python 3.2):
-------------------- bug.py --------------
class Foo(object):
pass
#def __str__(self): #if you have this defined, no abend
# return "a Foo"
Foo.__repr__ = Foo.__str__ # this will cause an abend.
#Foo.__str__ = Foo.__repr__ #do this instead, no abend
foo = Foo()
print(str(foo))
------------------------------------------
for Python 3.2 the command:
C:\Temp>c:\python32\python bug.py
generates a popup:
python.exe - Application Error
The exception unknown software exception (0xc0000fd) occurred in the
application at location 0x1e08a325.
Click on OK to terminate the program
Click on CANCEL to debug the program
So it looks to me to be a current bug.
--
Duncan Booth http://kupuguy.blogspot.com
More information about the Python-list
mailing list