This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Jim.Jewett
Recipients Jim.Jewett
Date 2012-01-26.05:47:41
SpamBayes Score 6.305876e-09
Marked as misclassified No
Message-id <1327556862.47.0.690638642414.issue13871@psf.upfronthosting.co.za>
In-reply-to
Content
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ª'
History
Date User Action Args
2012-01-26 05:47:42Jim.Jewettsetrecipients: + Jim.Jewett
2012-01-26 05:47:42Jim.Jewettsetmessageid: <1327556862.47.0.690638642414.issue13871@psf.upfronthosting.co.za>
2012-01-26 05:47:41Jim.Jewettlinkissue13871 messages
2012-01-26 05:47:41Jim.Jewettcreate