[PEAK] Problem with peak.rules and Python < 2.5
Phillip J. Eby
pje at telecommunity.com
Thu Jun 19 18:28:52 EDT 2008
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.
More information about the PEAK
mailing list