[Python-Dev] bug or a feature? (original) (raw)

Scott Dial scott+python-dev at scottdial.com
Wed Jun 11 21:23:38 CEST 2008


Phillip J. Eby wrote:

That test is there to ensure that it interoperates with code using the AddOns library from the Cheeseshop; SQLAlchemy is not the source of the usage.

Now that's interesting. The AddOns library uses class objects as keys in the dict, but that doesn't says anything about the usage of locals(). At no point in the AddOns library is locals() abused like this, so even if one asserts that assignment to the dict returned by locals() is a bug, the underlying behavior of interest is whether dict is allowed to have non-string keys.

from peak.util.addons import AddOn class C: pass class A(AddOn): pass spam = C() print spam.dict {} A(spam) print spam.dict {<class 'A'>: <A object at ...>}

If non-string keys are not allowed in dict, then the AddOns library should be changed to add another dict to the object of interest to track these AddOn instances.

-Scott

-- Scott Dial scott at scottdial.com scodial at cs.indiana.edu



More information about the Python-Dev mailing list