Patchwork [05,of,10,STABLE] mail: catch LookupError in headdecode()

login
register
mail settings
Submitter Denis Laxalde
Date Oct. 24, 2019, 3:30 p.m.
Message ID <d1382260a9c847b4650c.1571931036@steppe.local>
Download mbox | patch
Permalink /patch/42571/
State Accepted
Headers show

Comments

Denis Laxalde - Oct. 24, 2019, 3:30 p.m.
# HG changeset patch
# User Denis Laxalde <denis.laxalde@logilab.fr>
# Date 1571920284 -7200
#      Thu Oct 24 14:31:24 2019 +0200
# Branch stable
# Node ID d1382260a9c847b4650c95372161541ac82cb56b
# Parent  0e2dd04f18a589180731471cc6a62a10f097bc59
mail: catch LookupError in headdecode()

We already catch this exception in _encode() (called by headencode()).
It gets raised when running test-notify.t with Python 3.

Patch

diff --git a/mercurial/mail.py b/mercurial/mail.py
--- a/mercurial/mail.py
+++ b/mercurial/mail.py
@@ -459,7 +459,7 @@  def headdecode(s):
             try:
                 uparts.append(part.decode(charset))
                 continue
-            except UnicodeDecodeError:
+            except (UnicodeDecodeError, LookupError):
                 pass
         # On Python 3, decode_header() may return either bytes or unicode
         # depending on whether the header has =?<charset>? or not