>Barry Finkel wrote:
>>
>>I ran a test with a test list on my test virtual machine, and this is
>>what is happening.  The line in the "-f" file for sync_members
>>
>>     bsf-cr...@example.com          (New 1 (zzz))
>>
>>is causing all of the succeeding lines in that file to be treated as
>>part of the parenthesized "name-comments" field for this new
>>bsf-crane entry.  The command


Yes, I am able to duplicate this issue with email 3.0.1
Utils.getaddresses(), but only if the input file is 'unix format'
(<LF> line terminators and only if the succeeding lines also have the
'name' in a comment. If the file is 'dos format' - i.e. <CRLF> line
terminators, the problem does not occur. Also, I don't think it occurs
with email 4.0.1 with either input format. And if there are lines of
the form "Display Name <u...@example.com>", the first of those and the
subsequent lines will be OK.

The underlying problem is in the _parseaddr module in the email package
which misses the second paren when a nested comment and the outer
comment terminate together

As a workaround, for sync_members, you could try the following. Find
this section

    # strip out lines we don't care about, they are comments (# in first
    # non-whitespace) or are blank
    for i in range(len(filemembers)-1, -1, -1):
        addr = filemembers[i].strip()
        if addr == '' or addr[:1] == '#':
            del filemembers[i]
            print _('Ignore  :  %(addr)30s')

add three lines so it becomes

    # strip out lines we don't care about, they are comments (# in first
    # non-whitespace) or are blank
    for i in range(len(filemembers)-1, -1, -1):
        addr = filemembers[i].strip()
        if addr == '' or addr[:1] == '#':
            del filemembers[i]
            print _('Ignore  :  %(addr)30s')
        else:
            # work around bug in email 3.0.1 Utils.getaddresses()
            filemembers[i] = addr + '\r\n'

The better fix is the attached _parseaddr.patch.txt for the 3.0.1
email/_parseaddr.py

-- 
Mark Sapiro <m...@msapiro.net>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan

--- _parseaddr.py.orig  2006-02-02 21:41:33.000000000 -0800
+++ _parseaddr.py       2010-02-03 16:46:42.250000000 -0800
@@ -359,6 +359,7 @@
                 break
             elif allowcomments and self.field[self.pos] == '(':
                 slist.append(self.getcomment())
+                continue        # have already advanced pos from getcomment
             elif self.field[self.pos] == '\\':
                 quote = True
             else:
------------------------------------------------------
Mailman-Users mailing list Mailman-Users@python.org
http://mail.python.org/mailman/listinfo/mailman-users
Mailman FAQ: http://wiki.list.org/x/AgA3
Security Policy: http://wiki.list.org/x/QIA9
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-users/archive%40jab.org

Reply via email to