comparison mercurial/extensions.py @ 31448:6419cd243017

encoding: add converter between native str and byte string This kind of encoding conversion is unavoidable on Python 3.
author Yuya Nishihara <yuya@tcha.org>
date Mon, 13 Mar 2017 09:12:56 -0700
parents 067add650129
children b98ee1a808bd
comparison
equal deleted inserted replaced
31447:067add650129 31448:6419cd243017
106 return mod 106 return mod
107 107
108 def _forbytes(inst): 108 def _forbytes(inst):
109 """Portably format an import error into a form suitable for 109 """Portably format an import error into a form suitable for
110 %-formatting into bytestrings.""" 110 %-formatting into bytestrings."""
111 if pycompat.ispy3: 111 return encoding.strtolocal(str(inst))
112 return encoding.unitolocal(str(inst))
113 return inst
114 112
115 def _reportimporterror(ui, err, failed, next): 113 def _reportimporterror(ui, err, failed, next):
116 # note: this ui.debug happens before --debug is processed, 114 # note: this ui.debug happens before --debug is processed,
117 # Use --config ui.debug=1 to see them. 115 # Use --config ui.debug=1 to see them.
118 ui.debug('could not import %s (%s): trying %s\n' 116 ui.debug('could not import %s (%s): trying %s\n'