[issue25205] setattr accepts invalid identifiers
eryksun
report at bugs.python.org
Mon Sep 21 23:41:18 CEST 2015
eryksun added the comment:
The name can be any str/unicode string, including language keywords:
>>> setattr(o, 'def', 'allowed')
>>> getattr(o, 'def')
'allowed'
>>> o.def
File "<stdin>", line 1
o.def
^
SyntaxError: invalid syntax
and even an empty string:
>>> setattr(o, '', 'mu')
>>> getattr(o, '')
'mu'
This includes instances of str and unicode subclasses, at least in CPython.
----------
assignee: -> docs at python
components: +Documentation
nosy: +docs at python, eryksun
priority: normal -> low
versions: -Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25205>
_______________________________________
More information about the Python-bugs-list
mailing list