Mercurial > hg
comparison mercurial/patch.py @ 36035:95791b275b73
py3: convert content-type to bytes
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.
Differential Revision: https://phab.mercurial-scm.org/D2136
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 11 Feb 2018 10:49:00 -0800 |
parents | 8b6dd3922f70 |
children | 04984f2e50ae |
comparison
equal
deleted
inserted
replaced
36034:f3d8f61c425d | 36035:95791b275b73 |
---|---|
240 ui.debug('From: %s\n' % data['user']) | 240 ui.debug('From: %s\n' % data['user']) |
241 diffs_seen = 0 | 241 diffs_seen = 0 |
242 ok_types = ('text/plain', 'text/x-diff', 'text/x-patch') | 242 ok_types = ('text/plain', 'text/x-diff', 'text/x-patch') |
243 message = '' | 243 message = '' |
244 for part in msg.walk(): | 244 for part in msg.walk(): |
245 content_type = part.get_content_type() | 245 content_type = pycompat.bytestr(part.get_content_type()) |
246 ui.debug('Content-Type: %s\n' % content_type) | 246 ui.debug('Content-Type: %s\n' % content_type) |
247 if content_type not in ok_types: | 247 if content_type not in ok_types: |
248 continue | 248 continue |
249 payload = part.get_payload(decode=True) | 249 payload = part.get_payload(decode=True) |
250 m = diffre.search(payload) | 250 m = diffre.search(payload) |