comparison mercurial/pycompat.py @ 36556:63fe5ca93b13

pycompat: add support for encoding argument to our wrapper This only works on Python 3, but I'm about to need it for a regrettable hack in the convert code. Differential Revision: https://phab.mercurial-scm.org/D2524
author Augie Fackler <augie@google.com>
date Thu, 01 Mar 2018 17:46:34 -0500
parents 4cd2d1cc2a31
children e2b87e19c6ef
comparison
equal deleted inserted replaced
36555:c28de190e20a 36556:63fe5ca93b13
222 hasattr = _wrapattrfunc(builtins.hasattr) 222 hasattr = _wrapattrfunc(builtins.hasattr)
223 setattr = _wrapattrfunc(builtins.setattr) 223 setattr = _wrapattrfunc(builtins.setattr)
224 xrange = builtins.range 224 xrange = builtins.range
225 unicode = str 225 unicode = str
226 226
227 def open(name, mode='r', buffering=-1): 227 def open(name, mode='r', buffering=-1, encoding=None):
228 return builtins.open(name, sysstr(mode), buffering) 228 return builtins.open(name, sysstr(mode), buffering, encoding)
229 229
230 def _getoptbwrapper(orig, args, shortlist, namelist): 230 def _getoptbwrapper(orig, args, shortlist, namelist):
231 """ 231 """
232 Takes bytes arguments, converts them to unicode, pass them to 232 Takes bytes arguments, converts them to unicode, pass them to
233 getopt.getopt(), convert the returned values back to bytes and then 233 getopt.getopt(), convert the returned values back to bytes and then