# HG changeset patch # User Gregory Szorc # Date 1572720166 25200 # 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 -r aaa046919043 -r 2d31ef3fb494 hgdemandimport/demandimportpy3.py --- 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 )