notify: be more defensive aboute None values
authorGregory Szorc <gregory.szorc@gmail.com>
Sat, 26 Jan 2019 10:22:09 -0800
changeset 41404 43f9b8c0574b
parent 41403 e82288a9556c
child 41405 9b3be572ff0c
notify: be more defensive aboute None values encoding.strtolocal is the identity function on Python 2 but an actual string manipulation routine on Python 3. In some cases, we were passing None, which caused Python 3 to barf. Let's change the code to react properly when the value is None. Differential Revision: https://phab.mercurial-scm.org/D5713
hgext/notify.py
--- a/hgext/notify.py	Sat Jan 26 10:00:17 2019 -0800
+++ b/hgext/notify.py	Sat Jan 26 10:22:09 2019 -0800
@@ -367,8 +367,12 @@
             raise error.Abort(inst)
 
         # store sender and subject
-        sender = encoding.strtolocal(msg[r'From'])
-        subject = encoding.strtolocal(msg[r'Subject'])
+        sender = msg[r'From']
+        subject = msg[r'Subject']
+        if sender is not None:
+            sender = encoding.strtolocal(sender)
+        if subject is not None:
+            subject = encoding.strtolocal(subject)
         del msg[r'From'], msg[r'Subject']
 
         if not msg.is_multipart():