changeset 8615:659ecd26002c

vcs: fix subprocessio handling of hack for handling end-of-stream Address pytype warning: File "kallithea/lib/vcs/subprocessio.py", line 383, in __next__: No attribute 'stop' on listiterator[bytes] [attribute-error]
author Mads Kiilerich <mads@kiilerich.com>
date Tue, 18 Aug 2020 13:52:58 +0200
parents 43d9615facc6
children d435713db775
files kallithea/lib/vcs/subprocessio.py
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/vcs/subprocessio.py	Mon Aug 17 14:59:07 2020 +0200
+++ b/kallithea/lib/vcs/subprocessio.py	Tue Aug 18 13:52:58 2020 +0200
@@ -380,23 +380,23 @@
             if (returncode is not None # process has terminated
                 and returncode != 0
             ): # and it failed
-                self.output.stop()
+                getattr(self.output, 'stop', lambda: None)()
                 self.error.stop()
                 err = ''.join(self.error)
                 raise EnvironmentError("Subprocess exited due to an error:\n" + err)
         return next(self.output)
 
     def throw(self, type, value=None, traceback=None):
-        if self.output.length or not self.output.done_reading:
+        if getattr(self.output, 'length') or not getattr(self.output, 'done_reading'):
             raise type(value)
 
     def close(self):
         try:
-            self.process.terminate()
+            getattr(self.output, 'terminate', lambda: None)()
         except:
             pass
         try:
-            self.output.close()
+            getattr(self.output, 'close', lambda: None)()
         except:
             pass
         try: