debugcommands: prevent using `is False`
authorPulkit Goyal <7895pulkit@gmail.com>
Tue, 16 Feb 2021 20:38:14 +0530
changeset 46653 9306a16ca964
parent 46652 75832107ec07
child 46654 9ea6b75b4a95
debugcommands: prevent using `is False` I was touching this code in a future patch and marmoute warned about usage of `is False` here. Quoting marmoute: ``` "is False" is going to check if the object you have the very same object in memory than the one Python allocated for False (in practice 0) This will "mostly work" on cpython because of implementation details, but is semantically wrong and can start breaking unexpectedly ``` Differential Revision: https://phab.mercurial-scm.org/D10014
mercurial/debugcommands.py
--- a/mercurial/debugcommands.py	Tue Feb 16 18:43:42 2021 +0530
+++ b/mercurial/debugcommands.py	Tue Feb 16 20:38:14 2021 +0530
@@ -3870,10 +3870,10 @@
         tagsnode = cache.getfnode(node, computemissing=False)
         if tagsnode:
             tagsnodedisplay = hex(tagsnode)
-        elif tagsnode is False:
+        elif tagsnode is None:
+            tagsnodedisplay = b'missing'
+        else:
             tagsnodedisplay = b'invalid'
-        else:
-            tagsnodedisplay = b'missing'
 
         ui.write(b'%d %s %s\n' % (r, hex(node), tagsnodedisplay))