demandimportpy3: only use lazy extension loader on Python 3.6+
There was an inline comment denoting a bug in the lazy extension
loader on Python 3.5 which prevents it from working there. But the
code was not conditional on the Python version.
The result of this was a myriad of failures on Python 3.5 due to
getattr() and friends not working on lazy extension modules.
By making extension modules non-lazy on Python 3.5, we reduce the
number of test failures from 48 to 22 on that Python version.
--- a/hgdemandimport/demandimportpy3.py Sat Nov 02 15:33:39 2019 -0700
+++ b/hgdemandimport/demandimportpy3.py Sat Nov 02 11:42:46 2019 -0700
@@ -53,9 +53,13 @@
# This is 3.6+ because with Python 3.5 it isn't possible to lazily load
# extensions. See the discussion in https://bugs.python.org/issue26186 for more.
-_extensions_loader = _lazyloaderex.factory(
- importlib.machinery.ExtensionFileLoader
-)
+if sys.version_info[0:2] >= (3, 6):
+ _extensions_loader = _lazyloaderex.factory(
+ importlib.machinery.ExtensionFileLoader
+ )
+else:
+ _extensions_loader = importlib.machinery.ExtensionFileLoader
+
_bytecode_loader = _lazyloaderex.factory(
importlib.machinery.SourcelessFileLoader
)