Skip to content

Instantly share code, notes, and snippets.

@fumiyas
Last active October 15, 2018 17:33
Show Gist options
  • Save fumiyas/625e64e193fe17c3066efffcf8a75542 to your computer and use it in GitHub Desktop.
Save fumiyas/625e64e193fe17c3066efffcf8a75542 to your computer and use it in GitHub Desktop.
Mailman mm_cfg.py: Workaround for a bug of Python 2 email module
## Workaround for the following bug of Python 2 email module:
##
## ```console
## $ (
## echo 'from email.header import Header'
## echo 'print Header("X: =?ISO-2022-JP?Q?=1B$B%;%s=1B(B?=",maxlinelen=20)')
## ) |python2
## X: =?ISO-2022-JP?Q?=1B$B%;
## %s=1B(B?=
## ```
def email_generator_init_wrapper(self, *args, **kws):
email.generator.Generator.__init__orig(self, *args, **kws)
self._maxheaderlen = 0
import email.generator
email.generator.Generator.__init__orig = email.generator.Generator.__init__
email.generator.Generator.__init__ = email_generator_init_wrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment