[PATCH 1 of 4] mail: let headencode() return a native string
Denis Laxalde
denis at laxalde.org
Sat Nov 9 16:06:40 UTC 2019
# HG changeset patch
# User Denis Laxalde <denis at laxalde.org>
# Date 1573299914 -3600
# Sat Nov 09 12:45:14 2019 +0100
# Node ID 1c7a66bf3315f69036420e2b07b584abacfef881
# Parent a78a65c33b5aa84cc9c3ae5f7dad636d371f149c
mail: let headencode() return a native string
This is to avoid conversion to/from str on py3.
diff --git a/hgext/notify.py b/hgext/notify.py
--- a/hgext/notify.py
+++ b/hgext/notify.py
@@ -421,8 +421,8 @@ class notifier(object):
maxsubject = int(self.ui.config(b'notify', b'maxsubject'))
if maxsubject:
subject = stringutil.ellipsis(subject, maxsubject)
- msg[r'Subject'] = encoding.strfromlocal(
- mail.headencode(self.ui, subject, self.charsets, self.test)
+ msg[r'Subject'] = mail.headencode(
+ self.ui, subject, self.charsets, self.test
)
# try to make message have proper sender
diff --git a/mercurial/mail.py b/mercurial/mail.py
--- a/mercurial/mail.py
+++ b/mercurial/mail.py
@@ -365,13 +365,13 @@ def headencode(ui, s, charsets=None, dis
if not display:
# split into words?
s, cs = _encode(ui, s, charsets)
- return encoding.strtolocal(email.header.Header(s, cs).encode())
- return s
+ return email.header.Header(s, cs).encode()
+ return encoding.strfromlocal(s)
def _addressencode(ui, name, addr, charsets=None):
assert isinstance(addr, bytes)
- name = encoding.strfromlocal(headencode(ui, name, charsets))
+ name = headencode(ui, name, charsets)
try:
acc, dom = addr.split(b'@')
acc.decode('ascii')
More information about the Mercurial-devel
mailing list