mercurial/pycompat.py
author Gregory Szorc <gregory.szorc@gmail.com>
Wed, 06 Jul 2016 22:53:22 -0700
changeset 29508 d65ec41b6384
parent 29455 0c741fd6158a
child 29566 075146e85bb6
permissions -rw-r--r--
sslutil: move context options flags to _hostsettings Again, moving configuration determination to a single location.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28818
6041fb8f2da8 pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff changeset
     1
# pycompat.py - portability shim for python 3
6041fb8f2da8 pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff changeset
     2
#
6041fb8f2da8 pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff changeset
     3
# This software may be used and distributed according to the terms of the
6041fb8f2da8 pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff changeset
     4
# GNU General Public License version 2 or any later version.
6041fb8f2da8 pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff changeset
     5
6041fb8f2da8 pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff changeset
     6
"""Mercurial portability shim for python 3.
6041fb8f2da8 pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff changeset
     7
6041fb8f2da8 pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff changeset
     8
This contains aliases to hide python version-specific details from the core.
6041fb8f2da8 pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff changeset
     9
"""
6041fb8f2da8 pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff changeset
    10
6041fb8f2da8 pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff changeset
    11
from __future__ import absolute_import
6041fb8f2da8 pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff changeset
    12
6041fb8f2da8 pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff changeset
    13
try:
29324
b501579147f1 py3: conditionalize cPickle import by adding in util
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28882
diff changeset
    14
    import cPickle as pickle
b501579147f1 py3: conditionalize cPickle import by adding in util
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28882
diff changeset
    15
    pickle.dumps
b501579147f1 py3: conditionalize cPickle import by adding in util
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28882
diff changeset
    16
except ImportError:
b501579147f1 py3: conditionalize cPickle import by adding in util
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28882
diff changeset
    17
    import pickle
29405
fbe380dc227a pyflakes: use pycompat.pickles to prevent error
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 29324
diff changeset
    18
    pickle.dumps # silence pyflakes
29324
b501579147f1 py3: conditionalize cPickle import by adding in util
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28882
diff changeset
    19
b501579147f1 py3: conditionalize cPickle import by adding in util
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28882
diff changeset
    20
try:
29455
0c741fd6158a py3: conditionalize httplib import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29433
diff changeset
    21
    import httplib
0c741fd6158a py3: conditionalize httplib import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29433
diff changeset
    22
    httplib.HTTPException
0c741fd6158a py3: conditionalize httplib import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29433
diff changeset
    23
except ImportError:
0c741fd6158a py3: conditionalize httplib import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29433
diff changeset
    24
    import http.client as httplib
0c741fd6158a py3: conditionalize httplib import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29433
diff changeset
    25
    httplib.HTTPException
0c741fd6158a py3: conditionalize httplib import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29433
diff changeset
    26
0c741fd6158a py3: conditionalize httplib import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29433
diff changeset
    27
try:
29433
33770d2b6cf9 py3: conditionalize SocketServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29432
diff changeset
    28
    import SocketServer as socketserver
33770d2b6cf9 py3: conditionalize SocketServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29432
diff changeset
    29
    socketserver.ThreadingMixIn
33770d2b6cf9 py3: conditionalize SocketServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29432
diff changeset
    30
except ImportError:
33770d2b6cf9 py3: conditionalize SocketServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29432
diff changeset
    31
    import socketserver
33770d2b6cf9 py3: conditionalize SocketServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29432
diff changeset
    32
    socketserver.ThreadingMixIn
33770d2b6cf9 py3: conditionalize SocketServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29432
diff changeset
    33
33770d2b6cf9 py3: conditionalize SocketServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29432
diff changeset
    34
try:
29432
34b914ac573e py3: conditionalize xmlrpclib import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29431
diff changeset
    35
    import xmlrpclib
34b914ac573e py3: conditionalize xmlrpclib import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29431
diff changeset
    36
    xmlrpclib.Transport
34b914ac573e py3: conditionalize xmlrpclib import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29431
diff changeset
    37
except ImportError:
34b914ac573e py3: conditionalize xmlrpclib import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29431
diff changeset
    38
    import xmlrpc.client as xmlrpclib
34b914ac573e py3: conditionalize xmlrpclib import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29431
diff changeset
    39
    xmlrpclib.Transport
34b914ac573e py3: conditionalize xmlrpclib import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29431
diff changeset
    40
34b914ac573e py3: conditionalize xmlrpclib import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29431
diff changeset
    41
try:
29431
80880ad3fccd py3: conditionalize the urlparse import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29414
diff changeset
    42
    import urlparse
80880ad3fccd py3: conditionalize the urlparse import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29414
diff changeset
    43
    urlparse.urlparse
80880ad3fccd py3: conditionalize the urlparse import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29414
diff changeset
    44
except ImportError:
80880ad3fccd py3: conditionalize the urlparse import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29414
diff changeset
    45
    import urllib.parse as urlparse
80880ad3fccd py3: conditionalize the urlparse import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29414
diff changeset
    46
    urlparse.urlparse
80880ad3fccd py3: conditionalize the urlparse import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29414
diff changeset
    47
80880ad3fccd py3: conditionalize the urlparse import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 29414
diff changeset
    48
try:
28835
68a946e83188 pycompat: add util.stringio to handle py3 divergence
timeless <timeless@mozdev.org>
parents: 28834
diff changeset
    49
    import cStringIO as io
68a946e83188 pycompat: add util.stringio to handle py3 divergence
timeless <timeless@mozdev.org>
parents: 28834
diff changeset
    50
    stringio = io.StringIO
68a946e83188 pycompat: add util.stringio to handle py3 divergence
timeless <timeless@mozdev.org>
parents: 28834
diff changeset
    51
except ImportError:
68a946e83188 pycompat: add util.stringio to handle py3 divergence
timeless <timeless@mozdev.org>
parents: 28834
diff changeset
    52
    import io
68a946e83188 pycompat: add util.stringio to handle py3 divergence
timeless <timeless@mozdev.org>
parents: 28834
diff changeset
    53
    stringio = io.StringIO
68a946e83188 pycompat: add util.stringio to handle py3 divergence
timeless <timeless@mozdev.org>
parents: 28834
diff changeset
    54
68a946e83188 pycompat: add util.stringio to handle py3 divergence
timeless <timeless@mozdev.org>
parents: 28834
diff changeset
    55
try:
28818
6041fb8f2da8 pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff changeset
    56
    import Queue as _queue
28833
672fc23bf9cc pycompat: fix demand import handling of Queue
timeless <timeless@mozdev.org>
parents: 28818
diff changeset
    57
    _queue.Queue
28818
6041fb8f2da8 pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff changeset
    58
except ImportError:
6041fb8f2da8 pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff changeset
    59
    import queue as _queue
6041fb8f2da8 pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff changeset
    60
empty = _queue.Empty
6041fb8f2da8 pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff changeset
    61
queue = _queue.Queue
28834
2fac032c1269 pycompat: alias xrange to range in py3
timeless <timeless@mozdev.org>
parents: 28833
diff changeset
    62
28882
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    63
class _pycompatstub(object):
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    64
    pass
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    65
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    66
def _alias(alias, origin, items):
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    67
    """ populate a _pycompatstub
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    68
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    69
    copies items from origin to alias
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    70
    """
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    71
    def hgcase(item):
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    72
        return item.replace('_', '').lower()
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    73
    for item in items:
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    74
        try:
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    75
            setattr(alias, hgcase(item), getattr(origin, item))
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    76
        except AttributeError:
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    77
            pass
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    78
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    79
urlreq = _pycompatstub()
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    80
urlerr = _pycompatstub()
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    81
try:
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    82
    import urllib2
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    83
    import urllib
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    84
    _alias(urlreq, urllib, (
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    85
        "addclosehook",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    86
        "addinfourl",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    87
        "ftpwrapper",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    88
        "pathname2url",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    89
        "quote",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    90
        "splitattr",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    91
        "splitpasswd",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    92
        "splitport",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    93
        "splituser",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    94
        "unquote",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    95
        "url2pathname",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    96
        "urlencode",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    97
        "urlencode",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    98
    ))
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
    99
    _alias(urlreq, urllib2, (
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   100
        "AbstractHTTPHandler",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   101
        "BaseHandler",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   102
        "build_opener",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   103
        "FileHandler",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   104
        "FTPHandler",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   105
        "HTTPBasicAuthHandler",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   106
        "HTTPDigestAuthHandler",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   107
        "HTTPHandler",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   108
        "HTTPPasswordMgrWithDefaultRealm",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   109
        "HTTPSHandler",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   110
        "install_opener",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   111
        "ProxyHandler",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   112
        "Request",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   113
        "urlopen",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   114
    ))
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   115
    _alias(urlerr, urllib2, (
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   116
        "HTTPError",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   117
        "URLError",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   118
    ))
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   119
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   120
except ImportError:
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   121
    import urllib.request
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   122
    _alias(urlreq, urllib.request, (
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   123
        "AbstractHTTPHandler",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   124
        "addclosehook",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   125
        "addinfourl",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   126
        "BaseHandler",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   127
        "build_opener",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   128
        "FileHandler",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   129
        "FTPHandler",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   130
        "ftpwrapper",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   131
        "HTTPHandler",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   132
        "HTTPSHandler",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   133
        "install_opener",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   134
        "pathname2url",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   135
        "HTTPBasicAuthHandler",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   136
        "HTTPDigestAuthHandler",
29414
2646fbba4ca7 pycompat: add HTTPPasswordMgrWithDefaultRealm to Python 3 block
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29405
diff changeset
   137
        "HTTPPasswordMgrWithDefaultRealm",
28882
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   138
        "ProxyHandler",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   139
        "quote",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   140
        "Request",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   141
        "splitattr",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   142
        "splitpasswd",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   143
        "splitport",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   144
        "splituser",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   145
        "unquote",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   146
        "url2pathname",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   147
        "urlopen",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   148
    ))
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   149
    import urllib.error
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   150
    _alias(urlerr, urllib.error, (
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   151
        "HTTPError",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   152
        "URLError",
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   153
    ))
800ec7c048b0 pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents: 28835
diff changeset
   154
28834
2fac032c1269 pycompat: alias xrange to range in py3
timeless <timeless@mozdev.org>
parents: 28833
diff changeset
   155
try:
2fac032c1269 pycompat: alias xrange to range in py3
timeless <timeless@mozdev.org>
parents: 28833
diff changeset
   156
    xrange
2fac032c1269 pycompat: alias xrange to range in py3
timeless <timeless@mozdev.org>
parents: 28833
diff changeset
   157
except NameError:
2fac032c1269 pycompat: alias xrange to range in py3
timeless <timeless@mozdev.org>
parents: 28833
diff changeset
   158
    import builtins
2fac032c1269 pycompat: alias xrange to range in py3
timeless <timeless@mozdev.org>
parents: 28833
diff changeset
   159
    builtins.xrange = range