Abend with cls.__repr__ = cls.__str__ on Windows.

J Peyret jpeyret at gmail.com
Fri Mar 18 01:15:20 EDT 2011


On Mar 17, 9:37 pm, Terry Reedy <tjre... 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.
>
> --
> Terry Jan Reedy

Nope, that is it.  No need to upgrade, nor is there any urgency.  I
was just surprised to see it fail so brutally, is all.  I've only
encountered 2 or 3 core Python bugs at that level in about 13 yrs of
coding in it, so thought I'd post it, especially as it is so easy to
replicate.

Txs for your help

I actually have another really weird behavior in this program, but
haven't figured out yet what causes it so it is hard to tell if it's
an error on my part or another system bug.  I'll post it if I can
isolate a system error.

FWIW, what I am doing is using Configparser to assemble a bunch of
classes together to provide a reporting/diffing engine for database
comparisons.  The object compositions are all defined in an .ini file.

I've found Python + ini files are a great match for creating truly
flexible programs.  SQL queries, template strings and regular
expression patterns can be stored in the ini file and are easy to
modify without touching the core python code.  Pass a different ini
file => different behavior.  Xml is overkill for this and plays really
badly with relational <,> operators.

This is the next step for me, defining mostly separate classes and
assembling and initializing them based on ini file configuration info.



More information about the Python-list mailing list