tests: constant-fold a `pycompat.ispy3` in testlib/badserverext.py
authorManuel Jacob <me@manueljacob.de>
Tue, 31 May 2022 02:36:05 +0200
changeset 49298 425ca3428d03
parent 49297 402f9f0f9387
child 49299 4554e2e965e2
tests: constant-fold a `pycompat.ispy3` in testlib/badserverext.py
tests/testlib/badserverext.py
--- a/tests/testlib/badserverext.py	Tue May 31 02:19:07 2022 +0200
+++ b/tests/testlib/badserverext.py	Tue May 31 02:36:05 2022 +0200
@@ -49,7 +49,6 @@
 import socket
 
 from mercurial import (
-    pycompat,
     registrar,
 )
 
@@ -335,17 +334,13 @@
         object.__getattribute__(self, '_logfp').flush()
 
     def _close(self):
-        # Python 3 uses an io.BufferedIO instance. Python 2 uses some file
-        # object wrapper.
-        if pycompat.ispy3:
-            orig = object.__getattribute__(self, '_orig')
+        # We wrap an io.BufferedIO instance.
+        orig = object.__getattribute__(self, '_orig')
 
-            if hasattr(orig, 'raw'):
-                orig.raw._sock.shutdown(socket.SHUT_RDWR)
-            else:
-                self.close()
+        if hasattr(orig, 'raw'):
+            orig.raw._sock.shutdown(socket.SHUT_RDWR)
         else:
-            self._sock.shutdown(socket.SHUT_RDWR)
+            self.close()
 
     def read(self, size=-1):
         cond = object.__getattribute__(self, '_cond')