comparison mercurial/extensions.py @ 45962:3db545fccac1

extensions: avoid a crash when the version isn't properly byteified on py3 We already force bytestr on the `testedwith` and `buglink` attributes in dispatch.py when generating a bug report with a similar comment about not every extension being ported to py3. We should do the same here, so the function can be properly typed. Differential Revision: https://phab.mercurial-scm.org/D9433
author Matt Harbison <matt_harbison@yahoo.com>
date Fri, 27 Nov 2020 14:54:37 -0500
parents 89a2afe31e82
children 2cf61e66c6d0
comparison
equal deleted inserted replaced
45961:464539c305aa 45962:3db545fccac1
934 version = module.__version__ 934 version = module.__version__
935 else: 935 else:
936 version = b'' 936 version = b''
937 if isinstance(version, (list, tuple)): 937 if isinstance(version, (list, tuple)):
938 version = b'.'.join(pycompat.bytestr(o) for o in version) 938 version = b'.'.join(pycompat.bytestr(o) for o in version)
939 else:
940 # version data should be bytes, but not all extensions are ported
941 # to py3.
942 version = stringutil.forcebytestr(version)
939 return version 943 return version
940 944
941 945
942 def ismoduleinternal(module): 946 def ismoduleinternal(module):
943 exttestedwith = getattr(module, 'testedwith', None) 947 exttestedwith = getattr(module, 'testedwith', None)