# HG changeset patch
# User Matt Harbison <matt_harbi...@yahoo.com>
# Date 1520702528 18000
#      Sat Mar 10 12:22:08 2018 -0500
# Node ID e21d0c21f81315d012c4806359bc76aa40c89ad6
# Parent  963b4223d14fa419df2a82fbe47cd55075707b6a
util: forward __bool__()/__nonzero__() on fileobjectproxy

In trying to debug the Windows process hang in D2720, I changed the stderr pipe
to the peer to be os.devnull instead.  That caused sshpeer._cleanuppipes()[1] to
explode, complaining NoneType has no __iter__ attribute, even though the
previous line checked for None.

[1] 
https://www.mercurial-scm.org/repo/hg/file/b434965f984e/mercurial/sshpeer.py#l133

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -551,6 +551,11 @@ class fileobjectproxy(object):
 
         return getattr(object.__getattribute__(self, r'_orig'), name)
 
+    def __nonzero__(self):
+        return bool(object.__getattribute__(self, r'_orig'))
+
+    __bool__ = __nonzero__
+
     def __delattr__(self, name):
         return delattr(object.__getattribute__(self, r'_orig'), name)
 
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to