D3951: patchbomb: work around email module really wanting to write unicode data
durin42 (Augie Fackler)
phabricator at mercurial-scm.org
Mon Jul 16 23:16:06 UTC 2018
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D3951
AFFECTED FILES
hgext/patchbomb.py
CHANGE DETAILS
diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -139,6 +139,14 @@
default=None,
)
+class _filestrtobytesfacade(object):
+ def __init__(self, ui):
+ self._ui = ui
+ def write(self, data):
+ if not isinstance(data, bytes):
+ data = pycompat.bytesurl(data)
+ return self._ui.write(data)
+
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
@@ -783,7 +791,8 @@
if opts.get('test'):
ui.status(_('displaying '), subj, ' ...\n')
ui.pager('email')
- generator = emailgen.Generator(ui, mangle_from_=False)
+ generator = emailgen.Generator(_filestrtobytesfacade(ui),
+ mangle_from_=False)
try:
generator.flatten(m, 0)
ui.write('\n')
@@ -799,7 +808,8 @@
# Exim does not remove the Bcc field
del m['Bcc']
fp = stringio()
- generator = emailgen.Generator(fp, mangle_from_=False)
+ generator = emailgen.Generator(_filestrtobytesfacade(fp),
+ mangle_from_=False)
generator.flatten(m, 0)
sendmail(sender_addr, to + bcc + cc, fp.getvalue())
To: durin42, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list