diff options
author | Raymond Hettinger <python@rcn.com> | 2007-05-21 08:13:35 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2007-05-21 08:13:35 (GMT) |
commit | 0d6a8ccfb7b602c97fd3dd2a57eaa8138c811186 (patch) | |
tree | 918b8a852dd95fd1e28cef2a9d2cd6fbb53948c7 /Lib/collections.py | |
parent | 5faa75f3c15c70dd494e9cfcda39ab11f5ad9aa0 (diff) | |
download | cpython-0d6a8ccfb7b602c97fd3dd2a57eaa8138c811186.zip cpython-0d6a8ccfb7b602c97fd3dd2a57eaa8138c811186.tar.gz cpython-0d6a8ccfb7b602c97fd3dd2a57eaa8138c811186.tar.bz2 |
Replace assertion with straight error-checking.
Diffstat (limited to 'Lib/collections.py')
-rw-r--r-- | Lib/collections.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/collections.py b/Lib/collections.py index fa9a9a0..a2ce552 100644 --- a/Lib/collections.py +++ b/Lib/collections.py @@ -24,7 +24,8 @@ def NamedTuple(typename, s): """ field_names = s.split() - assert ''.join(field_names).replace('_', '').isalpha() # protect against exec attacks + if not ''.join([typename] + field_names).replace('_', '').isalpha(): + raise ValueError('Type names and field names can only contain alphanumeric characters and underscores') argtxt = ', '.join(field_names) reprtxt = ', '.join('%s=%%r' % name for name in field_names) template = '''class %(typename)s(tuple): |