[PATCH STABLE v2] demandimport: add _imp to ignore list

Gregory Szorc gregory.szorc at gmail.com
Fri Feb 26 06:40:04 UTC 2016


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1456468511 28800
#      Thu Feb 25 22:35:11 2016 -0800
# Branch stable
# Node ID 1d9f3f93a47481ffe155e8beb801ff56e7c22d46
# Parent  2d437a0f3355834a9485bbbeb30a52a052c98f19
demandimport: add _imp to ignore list

Mozilla is seeing an issue with demand importing of _imp
failing in pkg_resources/__init__.py:fixup_namespace_packages.
It strangely only reproduces when using a modern version of
setuptools/pip in certain scenarios. Adding _imp to the demand import
ignore list seems to make the problem go away.

diff --git a/mercurial/demandimport.py b/mercurial/demandimport.py
--- a/mercurial/demandimport.py
+++ b/mercurial/demandimport.py
@@ -211,16 +211,18 @@ def _demandimport(name, globals=None, lo
         for x in fromlist:
             processfromitem(mod, x)
 
         return mod
 
 ignore = [
     '__future__',
     '_hashlib',
+    # ImportError during pkg_resources/__init__.py:fixup_namespace_package
+    '_imp',
     '_xmlplus',
     'fcntl',
     'win32com.gen_py',
     '_winreg', # 2.7 mimetypes needs immediate ImportError
     'pythoncom',
     # imported by tarfile, not available under Windows
     'pwd',
     'grp',


More information about the Mercurial-devel mailing list