[PATCH 3 of 5] py3: conditionalize xmlrpclib import

Pulkit Goyal 7895pulkit at gmail.com
Mon Jun 27 09:46:42 EDT 2016


# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1467025657 -19800
#      Mon Jun 27 16:37:37 2016 +0530
# Node ID 1ce001af985fd4012db55f8034addb39234488d8
# Parent  dd47675f5ea2c782b2ef09a7bd0dcec18757d374
py3: conditionalize xmlrpclib import

The xmlrpclib library is renamed to xmlrpc.client in python 3

diff -r dd47675f5ea2 -r 1ce001af985f hgext/bugzilla.py
--- a/hgext/bugzilla.py	Mon Jun 27 16:16:10 2016 +0530
+++ b/hgext/bugzilla.py	Mon Jun 27 16:37:37 2016 +0530
@@ -281,7 +281,6 @@
 
 import re
 import time
-import xmlrpclib
 
 from mercurial.i18n import _
 from mercurial.node import short
@@ -293,6 +292,7 @@
 )
 
 urlparse = util.urlparse
+xmlrpclib = util.xmlrpclib
 
 # Note for extension authors: ONLY specify testedwith = 'internal' for
 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
diff -r dd47675f5ea2 -r 1ce001af985f mercurial/pycompat.py
--- a/mercurial/pycompat.py	Mon Jun 27 16:16:10 2016 +0530
+++ b/mercurial/pycompat.py	Mon Jun 27 16:37:37 2016 +0530
@@ -18,6 +18,13 @@
     pickle.dumps # silence pyflakes
 
 try:
+    import xmlrpclib
+    xmlrpclib.Transport
+except ImportError:
+    import xmlrpc.client as xmlrpclib
+    xmlrpclib.Transport
+
+try:
     import urlparse
     urlparse.urlparse
 except ImportError:
diff -r dd47675f5ea2 -r 1ce001af985f mercurial/util.py
--- a/mercurial/util.py	Mon Jun 27 16:16:10 2016 +0530
+++ b/mercurial/util.py	Mon Jun 27 16:37:37 2016 +0530
@@ -54,6 +54,7 @@
     # we do import urlreq, but we do it outside the loop
     #'urlreq',
     'stringio',
+    'xmlrpclib',
 ):
     globals()[attr] = getattr(pycompat, attr)
 
diff -r dd47675f5ea2 -r 1ce001af985f tests/test-check-py3-compat.t
--- a/tests/test-check-py3-compat.t	Mon Jun 27 16:16:10 2016 +0530
+++ b/tests/test-check-py3-compat.t	Mon Jun 27 16:37:37 2016 +0530
@@ -26,7 +26,7 @@
   doc/hgmanpage.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
   hgext/automv.py: error importing module: <SyntaxError> invalid syntax (commands.py, line *) (line *) (glob)
   hgext/blackbox.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
-  hgext/bugzilla.py: error importing module: <ImportError> No module named 'xmlrpclib' (line *) (glob)
+  hgext/bugzilla.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
   hgext/censor.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
   hgext/chgserver.py: error importing module: <ImportError> No module named 'SocketServer' (line *) (glob)
   hgext/children.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)


More information about the Mercurial-devel mailing list