Mercurial > public > mercurial-scm > hg
comparison mercurial/hook.py @ 36108:c4146cf4dd20
py3: use system strings when calling __import__
We must pass the native str type when importing.
Differential Revision: https://phab.mercurial-scm.org/D2154
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 11 Feb 2018 16:02:32 -0800 |
parents | 056a9c8813aa |
children | 9c636ec1ef37 |
comparison
equal
deleted
inserted
replaced
36107:bff95b002e33 | 36108:c4146cf4dd20 |
---|---|
47 if modpath and modfile: | 47 if modpath and modfile: |
48 sys.path = sys.path[:] + [modpath] | 48 sys.path = sys.path[:] + [modpath] |
49 modname = modfile | 49 modname = modfile |
50 with demandimport.deactivated(): | 50 with demandimport.deactivated(): |
51 try: | 51 try: |
52 obj = __import__(modname) | 52 obj = __import__(pycompat.sysstr(modname)) |
53 except (ImportError, SyntaxError): | 53 except (ImportError, SyntaxError): |
54 e1 = sys.exc_info() | 54 e1 = sys.exc_info() |
55 try: | 55 try: |
56 # extensions are loaded with hgext_ prefix | 56 # extensions are loaded with hgext_ prefix |
57 obj = __import__("hgext_%s" % modname) | 57 obj = __import__(r"hgext_%s" % pycompat.sysstr(modname)) |
58 except (ImportError, SyntaxError): | 58 except (ImportError, SyntaxError): |
59 e2 = sys.exc_info() | 59 e2 = sys.exc_info() |
60 if ui.tracebackflag: | 60 if ui.tracebackflag: |
61 ui.warn(_('exception from first failed import ' | 61 ui.warn(_('exception from first failed import ' |
62 'attempt:\n')) | 62 'attempt:\n')) |