--- /dev/null
+from email import message
+from email import utils
+
+
+def _formatparam(param, value=None, quote=True):
+ """This is _formatparam from Python 2.7"""
+ if value is not None and len(value) > 0:
+ # A tuple is used for RFC 2231 encoded parameter values where items
+ # are (charset, language, value). charset is a string, not a Charset
+ # instance.
+ if isinstance(value, tuple):
+ # Encode as per RFC 2231
+ param += '*'
+ value = utils.encode_rfc2231(value[2], value[0], value[1])
+ # BAW: Please check this. I think that if quote is set it should
+ # force quoting even if not necessary.
+ if quote or message.tspecials.search(value):
+ return '%s="%s"' % (param, utils.quote(value))
+ else:
+ return '%s=%s' % (param, value)
+ else:
+ return param
+
+
+# Replace with this _formatparam to avoid re-encoding non-ascii params
+message._formatparam = _formatparam
import sys, os
from mimedecode_version import __version__, \
__author__, __copyright__, __license__
+if sys.version_info[0] >= 3:
+ # Replace email.message._formatparam with _formatparam from Python 2.7
+ # to avoid re-encoding non-ascii params.
+ import formatparam_27
me = os.path.basename(sys.argv[0])
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 2 :: Only',
],
- py_modules = ['mimedecode_version'],
+ py_modules = ['formatparam_27', 'mimedecode_version'],
scripts = ['mimedecode.py'],
**kw
)