author | Yuya Nishihara <yuya@tcha.org> |
Sun, 14 Aug 2016 12:51:21 +0900 | |
changeset 29799 | 45fa8de47a0f |
parent 29798 | 31d588fcd2b9 |
child 29800 | 178c89e8519a |
permissions | -rw-r--r-- |
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 |
|
29584
06587edd1233
pycompat: make pycompat demandimport friendly
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29566
diff
changeset
|
13 |
import sys |
06587edd1233
pycompat: make pycompat demandimport friendly
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29566
diff
changeset
|
14 |
|
06587edd1233
pycompat: make pycompat demandimport friendly
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29566
diff
changeset
|
15 |
if sys.version_info[0] < 3: |
29324
b501579147f1
py3: conditionalize cPickle import by adding in util
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28882
diff
changeset
|
16 |
import cPickle as pickle |
29584
06587edd1233
pycompat: make pycompat demandimport friendly
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29566
diff
changeset
|
17 |
import cStringIO as io |
29455
0c741fd6158a
py3: conditionalize httplib import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29433
diff
changeset
|
18 |
import httplib |
29584
06587edd1233
pycompat: make pycompat demandimport friendly
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29566
diff
changeset
|
19 |
import Queue as _queue |
29433
33770d2b6cf9
py3: conditionalize SocketServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29432
diff
changeset
|
20 |
import SocketServer as socketserver |
29584
06587edd1233
pycompat: make pycompat demandimport friendly
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29566
diff
changeset
|
21 |
import urlparse |
29432
34b914ac573e
py3: conditionalize xmlrpclib import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29431
diff
changeset
|
22 |
import xmlrpclib |
29584
06587edd1233
pycompat: make pycompat demandimport friendly
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29566
diff
changeset
|
23 |
else: |
06587edd1233
pycompat: make pycompat demandimport friendly
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29566
diff
changeset
|
24 |
import http.client as httplib |
06587edd1233
pycompat: make pycompat demandimport friendly
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29566
diff
changeset
|
25 |
import io |
06587edd1233
pycompat: make pycompat demandimport friendly
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29566
diff
changeset
|
26 |
import pickle |
06587edd1233
pycompat: make pycompat demandimport friendly
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29566
diff
changeset
|
27 |
import queue as _queue |
06587edd1233
pycompat: make pycompat demandimport friendly
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29566
diff
changeset
|
28 |
import socketserver |
06587edd1233
pycompat: make pycompat demandimport friendly
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29566
diff
changeset
|
29 |
import urllib.parse as urlparse |
29432
34b914ac573e
py3: conditionalize xmlrpclib import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29431
diff
changeset
|
30 |
import xmlrpc.client as xmlrpclib |
29431
80880ad3fccd
py3: conditionalize the urlparse import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29414
diff
changeset
|
31 |
|
29798
31d588fcd2b9
py3: check python version to enable builtins hack
Yuya Nishihara <yuya@tcha.org>
parents:
29797
diff
changeset
|
32 |
if sys.version_info[0] >= 3: |
29797
965c91bad9e3
py3: move xrange alias next to import lines
Yuya Nishihara <yuya@tcha.org>
parents:
29779
diff
changeset
|
33 |
import builtins |
29799
45fa8de47a0f
py3: provide (del|get|has|set)attr wrappers that accepts bytes
Yuya Nishihara <yuya@tcha.org>
parents:
29798
diff
changeset
|
34 |
import functools |
29797
965c91bad9e3
py3: move xrange alias next to import lines
Yuya Nishihara <yuya@tcha.org>
parents:
29779
diff
changeset
|
35 |
builtins.xrange = range |
965c91bad9e3
py3: move xrange alias next to import lines
Yuya Nishihara <yuya@tcha.org>
parents:
29779
diff
changeset
|
36 |
|
29799
45fa8de47a0f
py3: provide (del|get|has|set)attr wrappers that accepts bytes
Yuya Nishihara <yuya@tcha.org>
parents:
29798
diff
changeset
|
37 |
def _wrapattrfunc(f): |
45fa8de47a0f
py3: provide (del|get|has|set)attr wrappers that accepts bytes
Yuya Nishihara <yuya@tcha.org>
parents:
29798
diff
changeset
|
38 |
@functools.wraps(f) |
45fa8de47a0f
py3: provide (del|get|has|set)attr wrappers that accepts bytes
Yuya Nishihara <yuya@tcha.org>
parents:
29798
diff
changeset
|
39 |
def w(object, name, *args): |
45fa8de47a0f
py3: provide (del|get|has|set)attr wrappers that accepts bytes
Yuya Nishihara <yuya@tcha.org>
parents:
29798
diff
changeset
|
40 |
if isinstance(name, bytes): |
45fa8de47a0f
py3: provide (del|get|has|set)attr wrappers that accepts bytes
Yuya Nishihara <yuya@tcha.org>
parents:
29798
diff
changeset
|
41 |
name = name.decode(u'utf-8') |
45fa8de47a0f
py3: provide (del|get|has|set)attr wrappers that accepts bytes
Yuya Nishihara <yuya@tcha.org>
parents:
29798
diff
changeset
|
42 |
return f(object, name, *args) |
45fa8de47a0f
py3: provide (del|get|has|set)attr wrappers that accepts bytes
Yuya Nishihara <yuya@tcha.org>
parents:
29798
diff
changeset
|
43 |
return w |
45fa8de47a0f
py3: provide (del|get|has|set)attr wrappers that accepts bytes
Yuya Nishihara <yuya@tcha.org>
parents:
29798
diff
changeset
|
44 |
|
45fa8de47a0f
py3: provide (del|get|has|set)attr wrappers that accepts bytes
Yuya Nishihara <yuya@tcha.org>
parents:
29798
diff
changeset
|
45 |
delattr = _wrapattrfunc(builtins.delattr) |
45fa8de47a0f
py3: provide (del|get|has|set)attr wrappers that accepts bytes
Yuya Nishihara <yuya@tcha.org>
parents:
29798
diff
changeset
|
46 |
getattr = _wrapattrfunc(builtins.getattr) |
45fa8de47a0f
py3: provide (del|get|has|set)attr wrappers that accepts bytes
Yuya Nishihara <yuya@tcha.org>
parents:
29798
diff
changeset
|
47 |
hasattr = _wrapattrfunc(builtins.hasattr) |
45fa8de47a0f
py3: provide (del|get|has|set)attr wrappers that accepts bytes
Yuya Nishihara <yuya@tcha.org>
parents:
29798
diff
changeset
|
48 |
setattr = _wrapattrfunc(builtins.setattr) |
45fa8de47a0f
py3: provide (del|get|has|set)attr wrappers that accepts bytes
Yuya Nishihara <yuya@tcha.org>
parents:
29798
diff
changeset
|
49 |
|
29584
06587edd1233
pycompat: make pycompat demandimport friendly
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29566
diff
changeset
|
50 |
stringio = io.StringIO |
28818
6041fb8f2da8
pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
51 |
empty = _queue.Empty |
6041fb8f2da8
pycompat: add empty and queue to handle py3 divergence
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
52 |
queue = _queue.Queue |
28834
2fac032c1269
pycompat: alias xrange to range in py3
timeless <timeless@mozdev.org>
parents:
28833
diff
changeset
|
53 |
|
28882
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
54 |
class _pycompatstub(object): |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
55 |
pass |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
56 |
|
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
57 |
def _alias(alias, origin, items): |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
58 |
""" populate a _pycompatstub |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
59 |
|
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
60 |
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
|
61 |
""" |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
62 |
for item in items: |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
63 |
try: |
29779
997e8cf4d0a2
pycompat: avoid using an extra function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29778
diff
changeset
|
64 |
lcase = item.replace('_', '').lower() |
997e8cf4d0a2
pycompat: avoid using an extra function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29778
diff
changeset
|
65 |
setattr(alias, lcase, getattr(origin, item)) |
28882
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
66 |
except AttributeError: |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
67 |
pass |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
68 |
|
29566
075146e85bb6
py3: conditionalize BaseHTTPServer, SimpleHTTPServer and CGIHTTPServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29455
diff
changeset
|
69 |
httpserver = _pycompatstub() |
28882
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
70 |
urlreq = _pycompatstub() |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
71 |
urlerr = _pycompatstub() |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
72 |
try: |
29566
075146e85bb6
py3: conditionalize BaseHTTPServer, SimpleHTTPServer and CGIHTTPServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29455
diff
changeset
|
73 |
import BaseHTTPServer |
075146e85bb6
py3: conditionalize BaseHTTPServer, SimpleHTTPServer and CGIHTTPServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29455
diff
changeset
|
74 |
import CGIHTTPServer |
075146e85bb6
py3: conditionalize BaseHTTPServer, SimpleHTTPServer and CGIHTTPServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29455
diff
changeset
|
75 |
import SimpleHTTPServer |
28882
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
76 |
import urllib2 |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
77 |
import urllib |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
78 |
_alias(urlreq, urllib, ( |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
79 |
"addclosehook", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
80 |
"addinfourl", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
81 |
"ftpwrapper", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
82 |
"pathname2url", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
83 |
"quote", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
84 |
"splitattr", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
85 |
"splitpasswd", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
86 |
"splitport", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
87 |
"splituser", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
88 |
"unquote", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
89 |
"url2pathname", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
90 |
"urlencode", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
91 |
)) |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
92 |
_alias(urlreq, urllib2, ( |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
93 |
"AbstractHTTPHandler", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
94 |
"BaseHandler", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
95 |
"build_opener", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
96 |
"FileHandler", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
97 |
"FTPHandler", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
98 |
"HTTPBasicAuthHandler", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
99 |
"HTTPDigestAuthHandler", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
100 |
"HTTPHandler", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
101 |
"HTTPPasswordMgrWithDefaultRealm", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
102 |
"HTTPSHandler", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
103 |
"install_opener", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
104 |
"ProxyHandler", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
105 |
"Request", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
106 |
"urlopen", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
107 |
)) |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
108 |
_alias(urlerr, urllib2, ( |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
109 |
"HTTPError", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
110 |
"URLError", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
111 |
)) |
29566
075146e85bb6
py3: conditionalize BaseHTTPServer, SimpleHTTPServer and CGIHTTPServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29455
diff
changeset
|
112 |
_alias(httpserver, BaseHTTPServer, ( |
075146e85bb6
py3: conditionalize BaseHTTPServer, SimpleHTTPServer and CGIHTTPServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29455
diff
changeset
|
113 |
"HTTPServer", |
075146e85bb6
py3: conditionalize BaseHTTPServer, SimpleHTTPServer and CGIHTTPServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29455
diff
changeset
|
114 |
"BaseHTTPRequestHandler", |
075146e85bb6
py3: conditionalize BaseHTTPServer, SimpleHTTPServer and CGIHTTPServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29455
diff
changeset
|
115 |
)) |
075146e85bb6
py3: conditionalize BaseHTTPServer, SimpleHTTPServer and CGIHTTPServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29455
diff
changeset
|
116 |
_alias(httpserver, SimpleHTTPServer, ( |
075146e85bb6
py3: conditionalize BaseHTTPServer, SimpleHTTPServer and CGIHTTPServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29455
diff
changeset
|
117 |
"SimpleHTTPRequestHandler", |
075146e85bb6
py3: conditionalize BaseHTTPServer, SimpleHTTPServer and CGIHTTPServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29455
diff
changeset
|
118 |
)) |
075146e85bb6
py3: conditionalize BaseHTTPServer, SimpleHTTPServer and CGIHTTPServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29455
diff
changeset
|
119 |
_alias(httpserver, CGIHTTPServer, ( |
075146e85bb6
py3: conditionalize BaseHTTPServer, SimpleHTTPServer and CGIHTTPServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29455
diff
changeset
|
120 |
"CGIHTTPRequestHandler", |
075146e85bb6
py3: conditionalize BaseHTTPServer, SimpleHTTPServer and CGIHTTPServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29455
diff
changeset
|
121 |
)) |
28882
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
122 |
|
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
123 |
except ImportError: |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
124 |
import urllib.request |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
125 |
_alias(urlreq, urllib.request, ( |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
126 |
"AbstractHTTPHandler", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
127 |
"addclosehook", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
128 |
"addinfourl", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
129 |
"BaseHandler", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
130 |
"build_opener", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
131 |
"FileHandler", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
132 |
"FTPHandler", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
133 |
"ftpwrapper", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
134 |
"HTTPHandler", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
135 |
"HTTPSHandler", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
136 |
"install_opener", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
137 |
"pathname2url", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
138 |
"HTTPBasicAuthHandler", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
139 |
"HTTPDigestAuthHandler", |
29414
2646fbba4ca7
pycompat: add HTTPPasswordMgrWithDefaultRealm to Python 3 block
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29405
diff
changeset
|
140 |
"HTTPPasswordMgrWithDefaultRealm", |
28882
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
141 |
"ProxyHandler", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
142 |
"quote", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
143 |
"Request", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
144 |
"splitattr", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
145 |
"splitpasswd", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
146 |
"splitport", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
147 |
"splituser", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
148 |
"unquote", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
149 |
"url2pathname", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
150 |
"urlopen", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
151 |
)) |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
152 |
import urllib.error |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
153 |
_alias(urlerr, urllib.error, ( |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
154 |
"HTTPError", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
155 |
"URLError", |
800ec7c048b0
pycompat: add util.urlerr util.urlreq classes for py3 compat
timeless <timeless@mozdev.org>
parents:
28835
diff
changeset
|
156 |
)) |
29566
075146e85bb6
py3: conditionalize BaseHTTPServer, SimpleHTTPServer and CGIHTTPServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29455
diff
changeset
|
157 |
import http.server |
075146e85bb6
py3: conditionalize BaseHTTPServer, SimpleHTTPServer and CGIHTTPServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29455
diff
changeset
|
158 |
_alias(httpserver, http.server, ( |
075146e85bb6
py3: conditionalize BaseHTTPServer, SimpleHTTPServer and CGIHTTPServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29455
diff
changeset
|
159 |
"HTTPServer", |
075146e85bb6
py3: conditionalize BaseHTTPServer, SimpleHTTPServer and CGIHTTPServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29455
diff
changeset
|
160 |
"BaseHTTPRequestHandler", |
075146e85bb6
py3: conditionalize BaseHTTPServer, SimpleHTTPServer and CGIHTTPServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29455
diff
changeset
|
161 |
"SimpleHTTPRequestHandler", |
075146e85bb6
py3: conditionalize BaseHTTPServer, SimpleHTTPServer and CGIHTTPServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29455
diff
changeset
|
162 |
"CGIHTTPRequestHandler", |
075146e85bb6
py3: conditionalize BaseHTTPServer, SimpleHTTPServer and CGIHTTPServer import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29455
diff
changeset
|
163 |
)) |