summaryrefslogtreecommitdiffstats
path: root/Lib/collections/__init__.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2014-06-24 22:21:24 (GMT)
committerRaymond Hettinger <python@rcn.com>2014-06-24 22:21:24 (GMT)
commitf2bbb651a8eafd0d5330bc62b38b402bce293916 (patch)
tree1e8bcc8be77aa6df2765a3bff6fa8a0b91baafd9 /Lib/collections/__init__.py
parent5c2f5ab46541c6cacd3a69f6b5bbdfdf3d78aff2 (diff)
parentbc000509e8ae782ef96c656885c3342d11fca3a6 (diff)
downloadcpython-f2bbb651a8eafd0d5330bc62b38b402bce293916.zip
cpython-f2bbb651a8eafd0d5330bc62b38b402bce293916.tar.gz
cpython-f2bbb651a8eafd0d5330bc62b38b402bce293916.tar.bz2
merge
Diffstat (limited to 'Lib/collections/__init__.py')
-rw-r--r--Lib/collections/__init__.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py
index a55fee1..1f41ff9 100644
--- a/Lib/collections/__init__.py
+++ b/Lib/collections/__init__.py
@@ -352,6 +352,7 @@ def namedtuple(typename, field_names, verbose=False, rename=False):
if isinstance(field_names, str):
field_names = field_names.replace(',', ' ').split()
field_names = list(map(str, field_names))
+ typename = str(typename)
if rename:
seen = set()
for index, name in enumerate(field_names):
@@ -362,6 +363,8 @@ def namedtuple(typename, field_names, verbose=False, rename=False):
field_names[index] = '_%d' % index
seen.add(name)
for name in [typename] + field_names:
+ if type(name) != str:
+ raise TypeError('Type names and field names must be strings')
if not name.isidentifier():
raise ValueError('Type names and field names must be valid '
'identifiers: %r' % name)