[Python-bugs-list] [ python-Bugs-829458 ] setattr(obj, BADNAME, value) does not raises exception

SourceForge.net noreply at sourceforge.net
Fri Oct 24 03:53:39 EDT 2003


Bugs item #829458, was opened at 2003-10-24 11:53
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=829458&group_id=5470

Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Dmitry Vasiliev (hdima)
Assigned to: Nobody/Anonymous (nobody)
Summary: setattr(obj, BADNAME, value) does not raises exception

Initial Comment:
Now I just realize that setattr() does not check value
of the  name argument but simply insert the named value
in __dict__ so setattr(obj, BADNAME, value) not equal
to obj.BADNAME = value. It's true for new and old style
classes and all python versions which I have tried
(1.5, 2.1, 2.2, 2.3). Should not setattr(obj, BADNAME,
value) raise appropriate exception (AttributeError or
maybe ValueError)?

For example:

>>> class Test: pass
...
>>> o = Test()
>>> setattr(o, "test.test", 100)
>>> setattr(o, "12345", 200)
>>> dir(o)
['12345', '__doc__', '__module__', 'test.test']

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=829458&group_id=5470



More information about the Python-bugs-list mailing list