demandimport: strictly compare identity of proxy object
authorYuya Nishihara <yuya@tcha.org>
Mon, 01 May 2017 13:43:31 +0900
changeset 32445 847233374434
parent 32444 57d6c0c74b1b
child 32446 63365e9621d6
demandimport: strictly compare identity of proxy object This looks better, and __eq__() may be overridden in an undesired way.
hgdemandimport/demandimportpy2.py
--- a/hgdemandimport/demandimportpy2.py	Tue May 23 08:49:01 2017 -0700
+++ b/hgdemandimport/demandimportpy2.py	Mon May 01 13:43:31 2017 +0900
@@ -130,12 +130,12 @@
                 subload(mod, x)
 
             # Replace references to this proxy instance with the actual module.
-            if locals and locals.get(head) == self:
+            if locals and locals.get(head) is self:
                 locals[head] = mod
 
             for modname in modrefs:
                 modref = sys.modules.get(modname, None)
-                if modref and getattr(modref, head, None) == self:
+                if modref and getattr(modref, head, None) is self:
                     setattr(modref, head, mod)
 
             object.__setattr__(self, r"_module", mod)