[Mailman-Developers] Uncaught runner exception: 'generator' object has no attribute 'insert'

Barry A. Warsaw barry@zope.com
Tue, 27 Nov 2001 02:20:03 -0500


Oops.  Okay, let's try this one!

-Barry

Index: MailCommandHandler.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/MailCommandHandler.py,v
retrieving revision 2.25
diff -u -r2.25 MailCommandHandler.py
--- MailCommandHandler.py	2001/11/27 04:26:25	2.25
+++ MailCommandHandler.py	2001/11/27 07:20:00
@@ -181,7 +181,12 @@
             if mo:
                 subject = mo.group('cmd')
 
-        lines = email.Iterators.body_line_iterator(msg)[:]
+        # We must have a real list because of the way we insert an element and
+        # iterate over it.  In email 0.x (pre-Python 2.2) body_line_iterator()
+        # returns a real list, but in email 1.x (Python 2.2), it returns a
+        # generator.  This is the only way to coerce it to a concrete list
+        # object in both cases.
+        lines = list(email.Iterators.body_line_iterator(msg))
 
         # Find out if the subject line has a command on it
         subjcmd = []