thirdparty: allow zope.interface.advice to be lazily imported
authorGregory Szorc <gregory.szorc@gmail.com>
Wed, 21 Mar 2018 18:13:40 -0700
changeset 37179 49630e75635d
parent 37178 68ee61822182
child 37180 922b3fae9c7d
thirdparty: allow zope.interface.advice to be lazily imported The symbol from this module is only used in functions. Let's access that symbol through its imported module so importing zope.interface.advice can be lazy. Differential Revision: https://phab.mercurial-scm.org/D2931
mercurial/thirdparty/zope/interface/declarations.py
--- a/mercurial/thirdparty/zope/interface/declarations.py	Wed Mar 21 19:52:30 2018 -0700
+++ b/mercurial/thirdparty/zope/interface/declarations.py	Wed Mar 21 18:13:40 2018 -0700
@@ -34,7 +34,7 @@
 from types import ModuleType
 import weakref
 
-from .advice import addClassAdvisor
+from . import advice as advicemod
 from .interface import InterfaceClass
 from .interface import SpecificationBase
 from .interface import Specification
@@ -451,7 +451,7 @@
         raise TypeError(name+" can be used only once in a class definition.")
 
     locals['__implements_advice_data__'] = interfaces, classImplements
-    addClassAdvisor(_implements_advice, depth=3)
+    advicemod.addClassAdvisor(_implements_advice, depth=3)
 
 def implements(*interfaces):
     """Declare interfaces implemented by instances of a class
@@ -732,7 +732,7 @@
 
     locals["__provides__"] = _normalizeargs(interfaces)
 
-    addClassAdvisor(_classProvides_advice, depth=2)
+    advicemod.addClassAdvisor(_classProvides_advice, depth=2)
 
 def _classProvides_advice(cls):
     # This entire approach is invalid under Py3K.  Don't even try to fix