brownplt / lambda-py

Other
58 stars 10 forks source link

Assigning arbitrary attributes to instances of object should be forbidden #61

Closed amtriathlon closed 11 years ago

amtriathlon commented 11 years ago

According to http://docs.python.org/3.2/library/functions.html#object: Note object does not have a dict, so you can’t assign arbitrary attributes to an instance of the object class.

This is tested in the following fragment of test_object_class.py (added in https://github.com/brownplt/lambda-py/commit/516948acf0db2f89a8f7488e9d38d294d3ef7704), which is commented out for now:

try:
    a.foo = 12
except (AttributeError, TypeError):
    pass
else:
    assert False, "object() should not allow setting a foo attribute"