[PATCH 1 of 4] demandimport: strictly compare identity of proxy object

Yuya Nishihara yuya at tcha.org
Wed May 24 15:38:34 UTC 2017


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1493613811 -32400
#      Mon May 01 13:43:31 2017 +0900
# Node ID 43dcc4aba63fb8af43758cb9ed89ae19bd95c4fa
# Parent  09a28b35aef55ffd4098fd37059850560bf5690a
demandimport: strictly compare identity of proxy object

This looks better, and __eq__() may be overridden in an undesired way.

diff --git a/hgdemandimport/demandimportpy2.py b/hgdemandimport/demandimportpy2.py
--- a/hgdemandimport/demandimportpy2.py
+++ b/hgdemandimport/demandimportpy2.py
@@ -130,12 +130,12 @@ class _demandmod(object):
                 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)


More information about the Mercurial-devel mailing list