[ZODB-Dev] More ExtensionClass coercion
Christian Reis
kiko at async.com.br
Sat Jun 28 21:13:16 EDT 2003
Jeremy, I see an XXX in the ExtensionClass ChangeLog:
2003-05-09 16:59 jeremy
* ExtensionClass/src/Missing.c: Don't coerce Missing.Value to a
non-numeric type.
Fixes crash reported by Tres Seaver. Missing.Value offered to
coerce itself to unicode. unicode_compare() blew up because it
expected that the other argument had been converted to unicode.
XXX But why does this implement coercion at all?
I've noticed an odd, related, `feature' in Persistent. The following
testcase is what I dug up to demonstrate. It only seems to happen with
*subclasses* of Persistent; Persistent itself works correctly, as do
classes derived from ExtensionClass.Base. Here:
from ZODB import Persistent
p = Persistent()
print 0 == p, p == 0, 0 < p, p > 0, 0 > p, p < 0
Prints out (correctly, afaict):
0 0 1 1 0 0
Now, see how this changes:
class Foo(klass): pass
p = Foo()
print 0 == p, p == 0, 0 < p, p > 0, 0 > p, p < 0
Results in:
1 0 0 1 0 0
This is also a coercion problem, AFAICT. It seems that subclasses of
Persistent have ob_type->tp_as_number set, but I couldn't track down
*where* it is being assigned; somewhere in ExtensionClass' setup, I
think.
(We have the same problem in IndexedCatalog, with our _ICPersistent
ExtensionClass that derives from Persistent.)
Take care,
--
Christian Reis, Senior Engineer, Async Open Source, Brazil.
http://async.com.br/~kiko/ | [+55 16] 261 2331 | NMFL
More information about the ZODB-Dev
mailing list