changeset 36432:1ca4e86c7265

util: handle fileno() on Python 3 throwing io.UnsupportedOperation Fortunately, the exception exists on Python 2 so we don't have to do something weirder than this. Differential Revision: https://phab.mercurial-scm.org/D2450
author Augie Fackler <augie@google.com>
date Mon, 26 Feb 2018 00:51:41 -0500
parents ec43960b03e8
children 433cfad4bc46
files mercurial/util.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util.py	Mon Feb 26 00:50:57 2018 -0500
+++ b/mercurial/util.py	Mon Feb 26 00:51:41 2018 -0500
@@ -26,6 +26,7 @@
 import gc
 import hashlib
 import imp
+import io
 import itertools
 import mmap
 import os
@@ -1178,7 +1179,10 @@
 
 def _isstdout(f):
     fileno = getattr(f, 'fileno', None)
-    return fileno and fileno() == sys.__stdout__.fileno()
+    try:
+        return fileno and fileno() == sys.__stdout__.fileno()
+    except io.UnsupportedOperation:
+        return False # fileno() raised UnsupportedOperation
 
 def shellenviron(environ=None):
     """return environ with optional override, useful for shelling out"""