diff --git a/hgdemandimport/demandimportpy2.py b/hgdemandimport/demandimportpy2.py
index 57d6c0c74b1bbc83e9a511a4a1fa8b57e2457046_aGdkZW1hbmRpbXBvcnQvZGVtYW5kaW1wb3J0cHkyLnB5..8472333744347bd802f5652597e88807413016ab_aGdkZW1hbmRpbXBvcnQvZGVtYW5kaW1wb3J0cHkyLnB5 100644
--- a/hgdemandimport/demandimportpy2.py
+++ b/hgdemandimport/demandimportpy2.py
@@ -130,8 +130,8 @@
                 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)
@@ -134,8 +134,8 @@
                 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)