Show More
@@ -36,6 +36,12 from . import tracing | |||||
36 |
|
36 | |||
37 | _deactivated = False |
|
37 | _deactivated = False | |
38 |
|
38 | |||
|
39 | # Python 3.5's LazyLoader doesn't work for some reason. | |||
|
40 | # https://bugs.python.org/issue26186 is a known issue with extension | |||
|
41 | # importing. But it appears to not have a meaningful effect with | |||
|
42 | # Mercurial. | |||
|
43 | _supported = sys.version_info[0:2] >= (3, 6) | |||
|
44 | ||||
39 |
|
45 | |||
40 | class _lazyloaderex(importlib.util.LazyLoader): |
|
46 | class _lazyloaderex(importlib.util.LazyLoader): | |
41 | """This is a LazyLoader except it also follows the _deactivated global and |
|
47 | """This is a LazyLoader except it also follows the _deactivated global and | |
@@ -51,15 +57,9 class _lazyloaderex(importlib.util.LazyL | |||||
51 | super().exec_module(module) |
|
57 | super().exec_module(module) | |
52 |
|
58 | |||
53 |
|
59 | |||
54 | # This is 3.6+ because with Python 3.5 it isn't possible to lazily load |
|
|||
55 | # extensions. See the discussion in https://bugs.python.org/issue26186 for more. |
|
|||
56 | if sys.version_info[0:2] >= (3, 6): |
|
|||
57 |
|
|
60 | _extensions_loader = _lazyloaderex.factory( | |
58 |
|
|
61 | importlib.machinery.ExtensionFileLoader | |
59 | ) |
|
62 | ) | |
60 | else: |
|
|||
61 | _extensions_loader = importlib.machinery.ExtensionFileLoader |
|
|||
62 |
|
||||
63 | _bytecode_loader = _lazyloaderex.factory( |
|
63 | _bytecode_loader = _lazyloaderex.factory( | |
64 | importlib.machinery.SourcelessFileLoader |
|
64 | importlib.machinery.SourcelessFileLoader | |
65 | ) |
|
65 | ) | |
@@ -97,6 +97,9 def disable(): | |||||
97 |
|
97 | |||
98 |
|
98 | |||
99 | def enable(): |
|
99 | def enable(): | |
|
100 | if not _supported: | |||
|
101 | return | |||
|
102 | ||||
100 | sys.path_hooks.insert(0, _makefinder) |
|
103 | sys.path_hooks.insert(0, _makefinder) | |
101 |
|
104 | |||
102 |
|
105 |
@@ -22,6 +22,10 if subprocess.call( | |||||
22 | if sys.flags.optimize: |
|
22 | if sys.flags.optimize: | |
23 | sys.exit(80) |
|
23 | sys.exit(80) | |
24 |
|
24 | |||
|
25 | # The demand importer doesn't work on Python 3.5. | |||
|
26 | if sys.version_info[0:2] == (3, 5): | |||
|
27 | sys.exit(80) | |||
|
28 | ||||
25 | if ispy3: |
|
29 | if ispy3: | |
26 | from importlib.util import _LazyModule |
|
30 | from importlib.util import _LazyModule | |
27 |
|
31 |
General Comments 0
You need to be logged in to leave comments.
Login now