Skip to content

Commit fc0176d

Browse files
committed
[tests] use python3 for authproxy.py
1 parent 2c66cea commit fc0176d

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

test/functional/test_framework/authproxy.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,14 @@
3333
- uses standard Python json lib
3434
"""
3535

36-
try:
37-
import http.client as httplib
38-
except ImportError:
39-
import httplib
4036
import base64
4137
import decimal
38+
import http.client
4239
import json
4340
import logging
4441
import socket
4542
import time
46-
try:
47-
import urllib.parse as urlparse
48-
except ImportError:
49-
import urlparse
43+
import urllib.parse
5044

5145
USER_AGENT = "AuthServiceProxy/0.1"
5246

@@ -60,7 +54,7 @@ def __init__(self, rpc_error):
6054
errmsg = '%(message)s (%(code)i)' % rpc_error
6155
except (KeyError, TypeError):
6256
errmsg = ''
63-
Exception.__init__(self, errmsg)
57+
super().__init__(errmsg)
6458
self.error = rpc_error
6559

6660

@@ -77,7 +71,7 @@ def __init__(self, service_url, service_name=None, timeout=HTTP_TIMEOUT, connect
7771
self.__service_url = service_url
7872
self._service_name = service_name
7973
self.ensure_ascii = ensure_ascii # can be toggled on the fly by tests
80-
self.__url = urlparse.urlparse(service_url)
74+
self.__url = urllib.parse.urlparse(service_url)
8175
if self.__url.port is None:
8276
port = 80
8377
else:
@@ -98,10 +92,10 @@ def __init__(self, service_url, service_name=None, timeout=HTTP_TIMEOUT, connect
9892
# Callables re-use the connection of the original proxy
9993
self.__conn = connection
10094
elif self.__url.scheme == 'https':
101-
self.__conn = httplib.HTTPSConnection(self.__url.hostname, port,
95+
self.__conn = http.client.HTTPSConnection(self.__url.hostname, port,
10296
timeout=timeout)
10397
else:
104-
self.__conn = httplib.HTTPConnection(self.__url.hostname, port,
98+
self.__conn = http.client.HTTPConnection(self.__url.hostname, port,
10599
timeout=timeout)
106100

107101
def __getattr__(self, name):
@@ -124,7 +118,7 @@ def _request(self, method, path, postdata):
124118
try:
125119
self.__conn.request(method, path, postdata, headers)
126120
return self._get_response()
127-
except httplib.BadStatusLine as e:
121+
except http.client.BadStatusLine as e:
128122
if e.line == "''": # if connection was closed, try again
129123
self.__conn.close()
130124
self.__conn.request(method, path, postdata, headers)

0 commit comments

Comments
 (0)