[PEAK] Problem with peak.rules and Python < 2.5

Christoph Zwerschke cito at online.de
Thu Jun 19 17:42:51 EDT 2008


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?

-- Christoph



More information about the PEAK mailing list