changeset 43327:ac33550f63e8 stable

py3: use stdlib's parseaddr() to get sender header in notify extension In Python 3, email headers are unicode string so using stringutil.email() will not work as it compares with bytestring. So let's use email.utils.parseaddr() from the stdlib which has a consistent behavior across Python versions. The same is done in patchbomb extension already.
author Denis Laxalde <denis.laxalde@logilab.fr>
date Thu, 24 Oct 2019 15:46:16 +0200
parents ef81de93143e
children 416041f97cc3
files hgext/notify.py
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/notify.py	Thu Oct 24 15:28:00 2019 +0200
+++ b/hgext/notify.py	Thu Oct 24 15:46:16 2019 +0200
@@ -148,6 +148,7 @@
 from __future__ import absolute_import
 
 import email.errors as emailerrors
+import email.utils as emailutils
 import fnmatch
 import hashlib
 import socket
@@ -450,7 +451,7 @@
             )
             mail.sendmail(
                 self.ui,
-                stringutil.email(msg[r'From']),
+                emailutils.parseaddr(msg[r'From'])[1],
                 subs,
                 msgtext,
                 mbox=self.mbox,