components/mercurial/patches/demandimport.patch
author pkidd <patrick.kidd@oracle.com>
Fri, 14 Oct 2016 09:29:30 -0700
branchs11u3-sru
changeset 7110 eef24b4f8a52
parent 5721 153e2c170241
permissions -rw-r--r--
Added tag 0.175.3.14.0.2.0, S11.3SRU14.2 for changeset 698485941206

Mercurial's demandload system is incompatible with sqlalchemy.

This was reported upstream as

    https://bz.mercurial-scm.org/show_bug.cgi?id=5085

and is available in the upstream repository in changesets c25e3fd38ff1 and
9ff7261cc0f5.

diff --git a/mercurial/demandimport.py b/mercurial/demandimport.py
--- a/mercurial/demandimport.py
+++ b/mercurial/demandimport.py
@@ -174,7 +174,12 @@ def _demandimport(name, globals=None, lo
             """
             symbol = getattr(mod, attr, nothing)
             if symbol is nothing:
-                symbol = _demandmod(attr, mod.__dict__, locals, level=1)
+                mn = '%s.%s' % (mod.__name__, attr)
+                if mn in ignore:
+                    importfunc = _origimport
+                else:
+                    importfunc = _demandmod
+                symbol = importfunc(attr, mod.__dict__, locals, level=1)
                 setattr(mod, attr, symbol)
 
             # Record the importing module references this symbol so we can
@@ -250,6 +255,7 @@ ignore = [
     '_sre', # issue4920
     'rfc822',
     'mimetools',
+    'sqlalchemy.events', # has import-time side effects (issue5085)
     # setuptools 8 expects this module to explode early when not on windows
     'distutils.msvc9compiler'
     ]