D12247: pycompat: remove first not ispy3 block

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Wed Mar 2 00:44:02 UTC 2022


indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We now require Python 3. So we can remove the first block supporting
  Python 2.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/pycompat.py

CHANGE DETAILS

diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -10,13 +10,20 @@
 
 from __future__ import absolute_import
 
+import builtins
+import concurrent.futures as futures
 import getopt
+import http.client as httplib
+import http.cookiejar as cookielib
 import inspect
 import json
 import os
+import queue
 import shlex
+import socketserver
 import sys
 import tempfile
+import xmlrpc.client as xmlrpclib
 
 ispy3 = sys.version_info[0] >= 3
 ispypy = '__pypy__' in sys.builtin_module_names
@@ -27,36 +34,12 @@
 
     TYPE_CHECKING = typing.TYPE_CHECKING
 
-if not ispy3:
-    import cookielib
-    import cPickle as pickle
-    import httplib
-    import Queue as queue
-    import SocketServer as socketserver
-    import xmlrpclib
-
-    from .thirdparty.concurrent import futures
-
-    def future_set_exception_info(f, exc_info):
-        f.set_exception_info(*exc_info)
 
-    # this is close enough for our usage
-    FileNotFoundError = OSError
+def future_set_exception_info(f, exc_info):
+    f.set_exception(exc_info[0])
 
-else:
-    import builtins
-    import concurrent.futures as futures
-    import http.cookiejar as cookielib
-    import http.client as httplib
-    import pickle
-    import queue as queue
-    import socketserver
-    import xmlrpc.client as xmlrpclib
 
-    def future_set_exception_info(f, exc_info):
-        f.set_exception(exc_info[0])
-
-    FileNotFoundError = builtins.FileNotFoundError
+FileNotFoundError = builtins.FileNotFoundError
 
 
 def identity(a):



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


More information about the Mercurial-devel mailing list