Patchwork D12306: chgserver: remove Python 2 support code

login
register
mail settings
Submitter phabricator
Date March 2, 2022, 11:31 p.m.
Message ID <differential-rev-PHID-DREV-abdixdfgyyjjyfssmai6-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50644/
State New
Headers show

Comments

phabricator - March 2, 2022, 11:31 p.m.
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The logic here is more complicated than most Python 2/3 support code.
  But the rewritten logic should be identical.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12306

AFFECTED FILES
  mercurial/chgserver.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
--- a/mercurial/chgserver.py
+++ b/mercurial/chgserver.py
@@ -439,16 +439,13 @@ 
         ui = self.ui
         for (ch, fp, fd), (cn, fn, mode) in zip(self._oldios, _iochannels):
             newfp = getattr(ui, fn)
-            # On Python 2, newfp and fp may be separate file objects associated
-            # with the same fd, so we must close newfp while it's associated
-            # with the client. Otherwise the new associated fd would be closed
-            # when newfp gets deleted. On Python 3, newfp is just a wrapper
-            # around fp even if newfp is not fp, so deleting newfp is safe.
-            if not (pycompat.ispy3 or newfp is fp):
+            # On Python 3, newfp is just a wrapper around fp even if newfp is
+            # not fp, so deleting newfp is safe.
+            if newfp is not fp:
                 newfp.close()
             # restore original fd: fp is open again
             try:
-                if (pycompat.ispy3 or newfp is fp) and 'w' in mode:
+                if newfp is fp and 'w' in mode:
                     # Discard buffered data which couldn't be flushed because
                     # of EPIPE. The data should belong to the current session
                     # and should never persist.