[ZODB-Dev] Another ExtensionClass incompatibility: __pow__()
Greg Ward
gward@mems-exchange.org
Fri, 30 Nov 2001 11:53:28 -0500
Sigh. In addition to ignoring __r{add,sub,mul,div}__() methods,
ExtensionClass also calls __pow__() differently.
If I define this:
from ExtensionClass import Base
class A (Base):
def __pow__ (self, n):
print n
then this:
a = A()
a**37
blows up like this:
File "ecpow.py", line 14, in ?
a**1
TypeError: __pow__() takes exactly 2 arguments (3 given)
Ie. ExtensionClass always passes the 'modulo' argument to __pow__(),
even in a context where it makes no sense (ie. from the "**" operator).
It appears that the way to code __pow__() so it work for both regular
classes and ExtensionClasses is:
def __pow__ (self, n, mod=None):
print n
Admittedly not a great hardship, but it's one more little thing.
So what is the future of ExtensionClass, anyways? Are the little
incompatibility bugs between classic Python classes and ExtensionClass
ever going to be fixed? Or has ExtensionClass been abandoned in favour
of a future ZODB based on new-style Python 2.2 classes? If so, when
will this future ZODB become reality?
Greg