On 04/21/2015 06:59 AM, Marco Stoecker wrote:
> 
> indeed it throws an exception:
> 
> user@machine:~# ./mailinglist_sync.sh
> Traceback (most recent call last):
>   File "/usr/sbin/sync_members", line 288, in <module>
>     main()
>   File "/usr/sbin/sync_members", line 259, in main
>     s = email.Utils.formataddr((name, addr)).encode(enc, 'replace')
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xf6 in position 8:
> ordinal not in range(128)


This looks like <https://bugs.launchpad.net/mailman/+bug/1243343> which
was initially addressed in Mailman 2.1.17 and further fixed in 2.1.18.
Your's appears to be a pre 2.1.17 version. A patch is attached.

-- 
Mark Sapiro <[email protected]>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan
=== modified file 'bin/sync_members'
--- bin/sync_members    2008-02-29 17:47:36 +0000
+++ bin/sync_members    2013-12-01 21:06:45 +0000
@@ -1,6 +1,6 @@
 #! @PYTHON@
 #
-# Copyright (C) 1998-2003 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-2013 by the Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -256,6 +256,10 @@
             try:
                 if not dryrun:
                     mlist.ApprovedAddMember(userdesc, welcome, notifyadmin)
+                # Avoid UnicodeError if name can't be decoded
+                if isinstance(name, str):
+                    name = unicode(name, errors='replace')
+                name = name.encode(enc, 'replace')
                 s = email.Utils.formataddr((name, addr)).encode(enc, 'replace')
                 print _('Added  : %(s)s')
             except Errors.MMAlreadyAMember:
@@ -276,6 +280,10 @@
                     # reasons is in the database.  Use a lower level remove to
                     # get rid of this member's entry
                     mlist.removeMember(addr)
+            # Avoid UnicodeError if name can't be decoded
+            if isinstance(name, str):
+                name = unicode(name, errors='replace')
+            name = name.encode(enc, 'replace')
             s = email.Utils.formataddr((name, addr)).encode(enc, 'replace')
             print _('Removed: %(s)s')
 

------------------------------------------------------
Mailman-Users mailing list [email protected]
https://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: 
https://mail.python.org/mailman/options/mailman-users/archive%40jab.org

Reply via email to