[New-bugs-announce] [issue13821] misleading return from isidentifier

Jim Jewett report at bugs.python.org
Thu Jan 19 01:54:19 CET 2012


New submission from Jim Jewett <jimjjewett at gmail.com>:

Python identifiers are in NFKC form; string method .isidentifier() returns true on strings that are not in that form.  In some contexts, these non-canonical strings will be replaced with their NFKC equivalent, but in other contexts (such as the builtins hasattr, getattr, delattr) they will not.


>>> cha=chr(170)
>>> cha
'ª'

>>> cha.isidentifier()
True

>>> uc.normalize("NFKC", cha)
'a'

>>> obj.ª = 5
>>> hasattr(obj, "ª")
False
>>> obj.a
5

----------
components: Unicode
messages: 151597
nosy: Jim.Jewett, ezio.melotti
priority: normal
severity: normal
status: open
title: misleading return from isidentifier

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


More information about the New-bugs-announce mailing list