Patchwork D2167: py3: cast character set to bytes

login
register
mail settings
Submitter phabricator
Date Feb. 12, 2018, 3:45 a.m.
Message ID <differential-rev-PHID-DREV-m4u2b3aqfwfakhqojs6v-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/27636/
State Superseded
Headers show

Comments

phabricator - Feb. 12, 2018, 3:45 a.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The returned value from this function is eventually fed into
  email.charset.Charset.__init__. However, the standard library
  appears to handle both string types in Python 2 and 3. So there
  shouldn't be any problem returning a bytes here.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2167

AFFECTED FILES
  mercurial/mail.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/mail.py b/mercurial/mail.py
--- a/mercurial/mail.py
+++ b/mercurial/mail.py
@@ -187,7 +187,7 @@ 
 
 def codec2iana(cs):
     ''''''
-    cs = email.charset.Charset(cs).input_charset.lower()
+    cs = pycompat.sysbytes(email.charset.Charset(cs).input_charset.lower())
 
     # "latin1" normalizes to "iso8859-1", standard calls for "iso-8859-1"
     if cs.startswith("iso") and not cs.startswith("iso-"):