[Python-checkins] r55487 - python/trunk/Lib/collections.py

raymond.hettinger python-checkins at python.org
Mon May 21 10:13:39 CEST 2007


Author: raymond.hettinger
Date: Mon May 21 10:13:35 2007
New Revision: 55487

Modified:
   python/trunk/Lib/collections.py
Log:
Replace assertion with straight error-checking.

Modified: python/trunk/Lib/collections.py
==============================================================================
--- python/trunk/Lib/collections.py	(original)
+++ python/trunk/Lib/collections.py	Mon May 21 10:13:35 2007
@@ -24,7 +24,8 @@
     """
 
     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):


More information about the Python-checkins mailing list