[docs] [issue25205] setattr accepts invalid identifiers
report at bugs.python.org
Tue Sep 22 19:38:53 CEST 2015
W deW added the comment:
Thanks for the ref to issue14029. I think I see how it works. As long as the object's __dict__ accepts the attributeName as a key, it needs not be a valid string nor a string at all. Though the latter *is* checked for, and that in turn can be circumvented by adding the attribute to the __dict__ directly. An object can be made attribute to itself.
However, the documentation falls short here. So far, I haven't found where it defines "attribute". Is there any point in defining an attribute that cannot be addressed as an attribute if the parser doesn't allow it?
It seems to me that in order to catch programing errors early, the default behaviour should include checking the valid syntax of the attribute's name.
versions: +Python 2.7
Python tracker <report at bugs.python.org>
More information about the docs