[ZODB-Dev] Wierd vars() behavior

Jeremy Hylton jeremy@zope.com
Thu, 21 Mar 2002 10:54:18 -0500


>>>>> "NS" == Neil Schemenauer <nas@mems-exchange.org> writes:

  NS> This is with Zope-3x-branch:
  -> user_db.users
  NS>     <Persistence.BTrees.OOBTree.OOBTree object at 0x8410574>
  -> vars(user_db.users)
  NS>     <weakref at 0x842e9c4; to
  NS>     'Persistence.BTrees.OOBTree.OOBTree' at 0x8410574>

  NS> What magic is this?

I guess the __dict__ isn't a real dict, perhaps a weak reference to a
dict.  I don't know at all.

  -> from Persistence.BTrees import OOBTree -> t = OOBTree() -> t
  NS>     <Persistence.BTrees.OOBTree.OOBTree object at 0x841eae4>
  -> vars(t)
  NS>     {}

  NS> So vars() on a new BTree seems to work.  Is this a bug or
  NS> expected behavior?

I assume the following is true: vars(t) is t.__dict__

A BTree object appears to have an __dict__.  This surprises me a
little :-).  Things that don't surprise me: The __dict__ is empty.
You can't add attributes to it.

I suppose this is a bug, but I don't understand clearly enough to be
sure.  I think vars(OOBTree()) should raise a TypeError, just like
vars(object()).

Jeremy