Mercurial > hg
changeset 29431:80880ad3fccd
py3: conditionalize the urlparse import
The urlparse library is renamed to urllib.parse in python 3
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Mon, 27 Jun 2016 16:16:10 +0530 |
parents | 72065b3b90a4 |
children | 34b914ac573e |
files | hgext/bugzilla.py mercurial/pycompat.py mercurial/util.py tests/test-check-py3-compat.t tests/tinyproxy.py |
diffstat | 5 files changed, 15 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/bugzilla.py Mon Jun 27 15:53:38 2016 +0530 +++ b/hgext/bugzilla.py Mon Jun 27 16:16:10 2016 +0530 @@ -281,7 +281,6 @@ import re import time -import urlparse import xmlrpclib from mercurial.i18n import _ @@ -293,6 +292,8 @@ util, ) +urlparse = util.urlparse + # Note for extension authors: ONLY specify testedwith = 'internal' for # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should # be specifying the version(s) of Mercurial they are tested with, or
--- a/mercurial/pycompat.py Mon Jun 27 15:53:38 2016 +0530 +++ b/mercurial/pycompat.py Mon Jun 27 16:16:10 2016 +0530 @@ -18,6 +18,13 @@ pickle.dumps # silence pyflakes try: + import urlparse + urlparse.urlparse +except ImportError: + import urllib.parse as urlparse + urlparse.urlparse + +try: import cStringIO as io stringio = io.StringIO except ImportError:
--- a/mercurial/util.py Mon Jun 27 15:53:38 2016 +0530 +++ b/mercurial/util.py Mon Jun 27 16:16:10 2016 +0530 @@ -50,6 +50,7 @@ 'pickle', 'queue', 'urlerr', + 'urlparse', # we do import urlreq, but we do it outside the loop #'urlreq', 'stringio',
--- a/tests/test-check-py3-compat.t Mon Jun 27 15:53:38 2016 +0530 +++ b/tests/test-check-py3-compat.t Mon Jun 27 16:16:10 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 'urlparse' (line *) (glob) + hgext/bugzilla.py: error importing module: <ImportError> No module named 'xmlrpclib' (line *) (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)
--- a/tests/tinyproxy.py Mon Jun 27 15:53:38 2016 +0530 +++ b/tests/tinyproxy.py Mon Jun 27 16:16:10 2016 +0530 @@ -20,7 +20,10 @@ import select import socket import sys -import urlparse + +from mercurial import util + +urlparse = util.urlparse class ProxyHandler (BaseHTTPServer.BaseHTTPRequestHandler): __base = BaseHTTPServer.BaseHTTPRequestHandler