[ZODB-Dev] BTrees and PersistentDict keys: bug or feature

Christian Reis kiko at async.com.br
Thu Aug 14 23:01:25 EDT 2003


(I suppose I push these things in annoying ways.)

    >>> x = OOBTree()
    >>> x[{1:1, 2:2, 3:3}] = 1

    >>> y = PersistentMapping({1:1, 2:2, 3:3})

    >>> x[y]
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
      KeyError: {3: 3, 2: 2, 1: 1}

However,

    >>> x[PersistentMapping({1:1, 2:2, 3:3})] = 0
    >>> x[{1:1, 2:2, 3:3}]
    1

Even more odd,

    >>> y = PersistentMapping({1:1, 2:2, 3:3})
    >>> x[y] = 1
    >>> x[{1:1, 2:2, 3:3}]
    1
    >>> x[{1:1, 2:2, 3:3}] = 2
    >>> x[y]
    2

This strikes me as odd, and the fact that it does work perfectly for
PersistentList indicates it's a problem. The check() module indicates
it works okay.

I've tried to track this down but I'm not having a large measure of
success. It *seems* to me that the problem is PersistentMapping's
__cmp__ method is not being called consistently, but ever since Tim
warned me of mixed-type comparisons I've been reluctant to spend a long
time staring at code when I see these issues.

Should I just try and band-aid it in my code?

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