[umessage] Fix header decoding with python 3.3+

Closes #149345

authorRémi Cardona <remi.cardona@free.fr>
changesetb1880f9578a3
branchdefault
phasepublic
hiddenno
parent revision#41f989d43378 Use inspect.isclass()
child revision#6e40d1db1551 Use isinstance() instead of types.{Tuple,List}Type
files modified by this revision
umessage.py
# HG changeset patch
# User Rémi Cardona <remi.cardona@free.fr>
# Date 1405580071 -7200
# Thu Jul 17 08:54:31 2014 +0200
# Node ID b1880f9578a3b7603a3c0e11ae74c5ffa10953b2
# Parent 41f989d43378c57e194cf960d66a50a39ca6c890
[umessage] Fix header decoding with python 3.3+

Closes #149345

diff --git a/umessage.py b/umessage.py
@@ -44,11 +44,15 @@
1      for decoded, charset in decode_header(string):
2          if not charset :
3              charset = 'iso-8859-15'
4          parts.append(unicode(decoded, charset, 'replace'))
5 
6 -    return u' '.join(parts)
7 +    if sys.version_info < (3, 3):
8 +        # decoding was non-RFC compliant wrt to whitespace handling
9 +        # see http://bugs.python.org/issue1079
10 +        return u' '.join(parts)
11 +    return u''.join(parts)
12 
13  def message_from_file(fd):
14      try:
15          return UMessage(email.message_from_file(fd))
16      except email.Errors.MessageParseError: