[New-bugs-announce] [issue14029] When using setattr identifiers can start with any character

Lyudmil Nenov report at bugs.python.org
Thu Feb 16 10:02:00 CET 2012


New submission from Lyudmil Nenov <lnenov at mm-sol.com>:

I am not sure if this is actually a bug. 

Given documentation @ http://docs.python.org/release/2.5.2/ref/identifiers.html, the issue is that setattr does not appear to check identifier for naming convention.

See a short example below. Running on windows

>>> sys.version_info(major=2, minor=7, micro=1, releaselevel='final', serial=0)
>>> sys.version_info
sys.version_info(major=2, minor=7, micro=1, releaselevel='final', serial=0)
>>> class Example():
	pass
>>> example = Example()
>>> example. at foo = 4
SyntaxError: invalid syntax
>>> setattr(example, '@foo', 'bar')
>>> dir(example)
['@foo', '__doc__', '__module__']
>>> example. at foo
SyntaxError: invalid syntax
>>> getattr(example, '@foo')
'bar'

----------
messages: 153468
nosy: lnenov
priority: normal
severity: normal
status: open
title: When using setattr identifiers can start with any character
type: behavior

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14029>
_______________________________________


More information about the New-bugs-announce mailing list