# HG changeset patch # User Gregory Szorc # Date 2019-11-02 18:42:46 # Node ID 2d31ef3fb4940b3beb41d32e03bdec8427c504f2 # Parent aaa046919043f77b17d0bb1504723ac9a56ccfc3 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. diff --git a/hgdemandimport/demandimportpy3.py b/hgdemandimport/demandimportpy3.py --- a/hgdemandimport/demandimportpy3.py +++ b/hgdemandimport/demandimportpy3.py @@ -53,9 +53,13 @@ class _lazyloaderex(importlib.util.LazyL # 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 )