Patchwork D2136: py3: convert content-type to bytes

login
register
mail settings
Submitter phabricator
Date Feb. 11, 2018, 10:57 p.m.
Message ID <differential-rev-PHID-DREV-bzs2s3alyfsg4r7jw7pr-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/27584/
State Superseded
Headers show

Comments

phabricator - Feb. 11, 2018, 10:57 p.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This fixes the exception:
  
    TypeError: %b requires a bytes-like object, or an object that
    implements __bytes__, not 'str'
  
  On the line:
  
    ui.debug('Content-Type: %s\n' % content_type)
  
  And it prevents additional exceptions that use the content_type
  variable later.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/patch.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -242,7 +242,7 @@ 
         ok_types = ('text/plain', 'text/x-diff', 'text/x-patch')
         message = ''
         for part in msg.walk():
-            content_type = part.get_content_type()
+            content_type = pycompat.bytestr(part.get_content_type())
             ui.debug('Content-Type: %s\n' % content_type)
             if content_type not in ok_types:
                 continue