New submission from Jim Jewett <[email protected]>:
collections.namedtuple raises a ValueError if any of the field names are not
valid identifiers, or are duplicates.
It does not normalize the identifiers when checking for duplicates.
(Similar issue with the typename)
>>> namedtuple("dup_fields", ["a", "a"])
Traceback (most recent call last):
File "<pyshell#23>", line 1, in <module>
namedtuple("dup_fields", ["a", "a"])
File "C:\python32\lib\collections.py", line 345, in namedtuple
raise ValueError('Encountered duplicate field name: %r' % name)
ValueError: Encountered duplicate field name: 'a'
>>> namedtuple("nfk_tester", ["a", "ª"])
Traceback (most recent call last):
File "<pyshell#22>", line 1, in <module>
namedtuple("nfk_tester", ["a", "ª"])
File "C:\python32\lib\collections.py", line 365, in namedtuple
raise SyntaxError(e.msg + ':\n\n' + class_definition)
File "<string>", line None
SyntaxError: duplicate argument 'a' in function definition:
...
and
>>> namedtuple("justª", "ª")
Traceback (most recent call last):
File "<pyshell#24>", line 1, in <module>
namedtuple("justª", "ª")
File "C:\python32\lib\collections.py", line 366, in namedtuple
result = namespace[typename]
KeyError: 'justª'
----------
messages: 151997
nosy: Jim.Jewett
priority: normal
severity: normal
status: open
title: namedtuple does not normalize field names when sanitizing
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue13871>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com