Mercurial > public > mercurial-scm > hg
diff mercurial/mail.py @ 11542:594b98846ce1 stable
mail: ensure that Python2.4 to 2.7 use the same header format
Wrapping format for long headers changed in Python2.7 (see Python issue1974).
Adopt the Python2.7 behaviour and backport it for 2.4-2.6
author | Nicolas Dumazet <nicdumz.commits@gmail.com> |
---|---|
date | Tue, 06 Jul 2010 18:24:04 +0900 |
parents | d6512b3e9ac0 |
children | 49463314c24f ee601a6264e0 |
line wrap: on
line diff
--- a/mercurial/mail.py Mon Jul 05 19:49:54 2010 +0900 +++ b/mercurial/mail.py Tue Jul 06 18:24:04 2010 +0900 @@ -10,6 +10,26 @@ import os, smtplib, socket, quopri import email.Header, email.MIMEText, email.Utils +_oldheaderinit = email.Header.Header.__init__ +def _unifiedheaderinit(self, *args, **kw): + """ + Python2.7 introduces a backwards incompatible change + (Python issue1974, r70772) in email.Generator.Generator code: + pre-2.7 code passed "continuation_ws='\t'" to the Header + constructor, and 2.7 removed this parameter. + + Default argument is continuation_ws=' ', which means that the + behaviour is different in <2.7 and 2.7 + + We consider the 2.7 behaviour to be preferable, but need + to have an unified behaviour for versions 2.4 to 2.7 + """ + # override continuation_ws + kw['continuation_ws'] = ' ' + _oldheaderinit(self, *args, **kw) + +email.Header.Header.__dict__['__init__'] = _unifiedheaderinit + def _smtp(ui): '''build an smtp connection and return a function to send mail''' local_hostname = ui.config('smtp', 'local_hostname')