Mercurial > hg-stable
diff hgext/notify.py @ 43326:ef81de93143e stable
py3: use a BytesParser in notify extension
This is the first step to make the "long line" case in test-notify.t
pass by fixing a UnicodeDecodeError on Python 3.
We alias a parsebytes() in mail module, similarly as we already have a
parse() function for Python 2 and Python 3 compatibility.
author | Denis Laxalde <denis.laxalde@logilab.fr> |
---|---|
date | Thu, 24 Oct 2019 15:28:00 +0200 |
parents | 7d912413a3ae |
children | ac33550f63e8 |
line wrap: on
line diff
--- a/hgext/notify.py Thu Oct 24 17:16:43 2019 +0200 +++ b/hgext/notify.py Thu Oct 24 15:28:00 2019 +0200 @@ -148,7 +148,6 @@ from __future__ import absolute_import import email.errors as emailerrors -import email.parser as emailparser import fnmatch import hashlib import socket @@ -382,9 +381,8 @@ ) return - p = emailparser.Parser() try: - msg = p.parsestr(encoding.strfromlocal(data)) + msg = mail.parsebytes(data) except emailerrors.MessageParseError as inst: raise error.Abort(inst)