[Python-checkins] cpython (3.4): Issue 21832: Require named tuple inputs to be exact strings
raymond.hettinger
python-checkins at python.org
Wed Jun 25 03:08:59 CEST 2014
http://hg.python.org/cpython/rev/5c60dd518182
changeset: 91373:5c60dd518182
branch: 3.4
parent: 91365:3bedc1846202
user: Raymond Hettinger <python at rcn.com>
date: Tue Jun 24 15:20:55 2014 -0700
summary:
Issue 21832: Require named tuple inputs to be exact strings
files:
Lib/collections/__init__.py | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py
--- a/Lib/collections/__init__.py
+++ b/Lib/collections/__init__.py
@@ -323,6 +323,7 @@
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):
@@ -333,6 +334,8 @@
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)
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list