changeset 4979:f1a2bd1dea77

issue2550877: Writing headers with the email module will use continuation_ws = ' ' now for python 2.5 and 2.6 when importing anypy.email_.
author Bernhard Reiter <bernhard@intevation.de>
date Mon, 16 Mar 2015 16:16:02 +0100
parents ac1f56d77cf5
children 13f8f88ad984
files CHANGES.txt roundup/anypy/email_.py roundup/cgi/client.py roundup/mailer.py test/test_mailgw.py
diffstat 5 files changed, 21 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES.txt	Mon Mar 16 16:11:52 2015 +0100
+++ b/CHANGES.txt	Mon Mar 16 16:16:02 2015 +0100
@@ -146,8 +146,9 @@
   initial patch (John Kristensen)
 - Documentation: configuration messages_to_author value "nosy" now documented
   in chapter "customizing". (Bernhard Reiter)
-- issue2550877 Five failures in test_mailgw.py because of duplicated headers
-  and more precise comparision. (Bernhard Reiter)
+- issue2550877 Failures in test_mailgw.py because of duplicated headers
+  and more precise comparision. Writing headers with the email module will use 
+  continuation_ws = ' ' now for python 2.5 and 2.6. (Bernhard Reiter)
 
 
 2013-07-06: 1.5.0
--- a/roundup/anypy/email_.py	Mon Mar 16 16:11:52 2015 +0100
+++ b/roundup/anypy/email_.py	Mon Mar 16 16:16:02 2015 +0100
@@ -1,7 +1,22 @@
 import re
 import binascii
+import email
 from email import quoprimime, base64mime
 
+## please import this file if you are using the email module
+#
+# a "monkey patch" to unify the behaviour of python 2.5 2.6 2.7
+# when generating header files, see http://bugs.python.org/issue1974
+# and https://hg.python.org/cpython/rev/5deb27042e5a/
+# can go away once the minimum requirement is python 2.7
+_oldheaderinit = email.Header.Header.__init__
+def _unifiedheaderinit(self, *args, **kw):
+    # override continuation_ws
+    kw['continuation_ws'] = ' '
+    _oldheaderinit(self, *args, **kw)
+email.Header.Header.__dict__['__init__'] = _unifiedheaderinit
+##
+
 try:
     # Python 2.5+
     from email.parser import FeedParser
--- a/roundup/cgi/client.py	Mon Mar 16 16:11:52 2015 +0100
+++ b/roundup/cgi/client.py	Mon Mar 16 16:16:02 2015 +0100
@@ -31,6 +31,7 @@
 from email.MIMEBase import MIMEBase
 from email.MIMEText import MIMEText
 from email.MIMEMultipart import MIMEMultipart
+import roundup.anypy.email_
 
 def initialiseSecurity(security):
     '''Create some Permissions and Roles on the security object
--- a/roundup/mailer.py	Mon Mar 16 16:11:52 2015 +0100
+++ b/roundup/mailer.py	Mon Mar 16 16:16:02 2015 +0100
@@ -16,6 +16,8 @@
 from email.mime.text import MIMEText
 from email.mime.multipart import MIMEMultipart
 
+from roundup.anypy import email_
+
 try:
     import pyme, pyme.core
 except ImportError:
--- a/test/test_mailgw.py	Mon Mar 16 16:11:52 2015 +0100
+++ b/test/test_mailgw.py	Mon Mar 16 16:16:02 2015 +0100
@@ -15,7 +15,6 @@
 import gpgmelib
 import unittest, tempfile, os, shutil, errno, imp, sys, difflib, time
 
-
 try:
     import pyme, pyme.core
 except ImportError:

Roundup Issue Tracker: http://roundup-tracker.org/