comparison mercurial/hook.py @ 32637:4b426ae96ff2

py3: ensure that we don't concat bytes and str and the end result is bytes Here obj.__module__ and obj.__name__ are str. Either we can convert them to bytes or use an r'' and convert back to bytes when concat is done. I preferred the later one since we are encoding only once here.
author Pulkit Goyal <7895pulkit@gmail.com>
date Thu, 01 Jun 2017 01:41:34 +0530
parents aff7b32b3c05
children c032e137e494
comparison
equal deleted inserted replaced
32636:e7eb7494e98d 32637:4b426ae96ff2
29 unmodified commands (e.g. mercurial.commands.update) can 29 unmodified commands (e.g. mercurial.commands.update) can
30 be run as hooks without wrappers to convert return values.''' 30 be run as hooks without wrappers to convert return values.'''
31 31
32 if callable(funcname): 32 if callable(funcname):
33 obj = funcname 33 obj = funcname
34 funcname = obj.__module__ + "." + obj.__name__ 34 funcname = pycompat.sysbytes(obj.__module__ + r"." + obj.__name__)
35 else: 35 else:
36 d = funcname.rfind('.') 36 d = funcname.rfind('.')
37 if d == -1: 37 if d == -1:
38 raise error.HookLoadError( 38 raise error.HookLoadError(
39 _('%s hook is invalid: "%s" not in a module') 39 _('%s hook is invalid: "%s" not in a module')