Re: Problem with peak.rules and Python < 2.5

"Phillip J. Eby" <pje-Wh6+Hckhi6HFNGf7iClzIwC/[email protected]>
Newsgroups gmane.comp.python.peak
Message-ID <[email protected]>
At 11:42 PM 6/19/2008 +0200, Christoph Zwerschke wrote:
>Please have a look at the following code:
>
>----------------------------
>
>import sys
>from peak.rules import when
>
>class X:
>     pass
>
>class Y(X):
>     pass
>
>x = Y()
>
>f = lambda x: "f"
>
>g = when(f, "isinstance(x, X)")(lambda x: "g")
>
>print sys.version.split()[0], isinstance(x, X), f(x)
>
>-----------------------------
>
>It is expected to print "g", but it prints "f" for Python < 2.5:
>
>2.3.5 True f
>2.4.4 True f
>2.5.2 True g
>
>It seems "isinstance" does not work with multilevel inheritance in 
>peak.rules for Py < 2.5. Is this a known problem? Can it be fixed?

That's quite odd - I found the problem to occur in all versions of 
Python, for the PEAK-Rules trunk...  it's a breakage resulting from 
the index refactoring I did last week.  Are you sure you're running 
identical versions of PEAK-Rules across Python versions?

In the meantime, I've added a test for this, and the fix.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.