Skip to content

Commit ff7f181

Browse files
committed
Revert "Fix DeprecationWarning on Python 3.8"
Fixes Supervisor#1276. Differences in behavior between the deprecated split functions and urlparse() cause this to fail under some conditions. For now, revert the changes. A new patch will be needed to fix the Python 3.8 warnings. It is better to have it work with warnings on 3.8 than to not work on many versions. This reverts commit de5e719.
1 parent 9e9a863 commit ff7f181

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

supervisor/http.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
except ImportError: # Windows
1313
import getpass as pwd
1414

15+
from supervisor.compat import urllib
1516
from supervisor.compat import sha1
1617
from supervisor.compat import as_bytes
1718
from supervisor.compat import as_string
18-
from supervisor.compat import urlparse
19-
2019
from supervisor.medusa import asyncore_25 as asyncore
2120
from supervisor.medusa import http_date
2221
from supervisor.medusa import http_server
@@ -316,8 +315,7 @@ def get_server_url(self):
316315

317316
if 'HTTP_HOST' in environ:
318317
host = environ['HTTP_HOST'].strip()
319-
parsed = urlparse.urlparse(host)
320-
hostname, port = parsed.hostname, str(parsed.port)
318+
hostname, port = urllib.splitport(host)
321319
else:
322320
hostname = environ['SERVER_NAME'].strip()
323321
port = environ['SERVER_PORT']

supervisor/xmlrpc.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99

1010
from supervisor.compat import xmlrpclib
1111
from supervisor.compat import StringIO
12+
from supervisor.compat import urllib
1213
from supervisor.compat import as_bytes
1314
from supervisor.compat import as_string
1415
from supervisor.compat import encodestring
1516
from supervisor.compat import decodestring
1617
from supervisor.compat import httplib
1718
from supervisor.compat import PY2
18-
from supervisor.compat import urlparse
1919

2020
from supervisor.medusa.http_server import get_header
2121
from supervisor.medusa.xmlrpc_handler import xmlrpc_handler
@@ -486,10 +486,13 @@ def __init__(self, username=None, password=None, serverurl=None):
486486
self.verbose = False
487487
self.serverurl = serverurl
488488
if serverurl.startswith('http://'):
489-
parsed = urlparse.urlparse(serverurl)
490-
host, port = parsed.hostname, parsed.port
489+
type, uri = urllib.splittype(serverurl)
490+
host, path = urllib.splithost(uri)
491+
host, port = urllib.splitport(host)
491492
if port is None:
492493
port = 80
494+
else:
495+
port = int(port)
493496
def get_connection(host=host, port=port):
494497
return httplib.HTTPConnection(host, port)
495498
self._get_connection = get_connection

0 commit comments

Comments
 (0)