Skip to content

Commit de5e719

Browse files
committed
Fix DeprecationWarning on Python 3.8
/home/travis/build/Supervisor/supervisor/supervisor/xmlrpc.py:489: DeprecationWarning: urllib.parse.splittype() is deprecated as of 3.8, use urllib.parse.urlparse() instead type, uri = urllib.splittype(serverurl) /home/travis/build/Supervisor/supervisor/supervisor/xmlrpc.py:490: DeprecationWarning: urllib.parse.splithost() is deprecated as of 3.8, use urllib.parse.urlparse() instead host, path = urllib.splithost(uri) /home/travis/build/Supervisor/supervisor/supervisor/xmlrpc.py:491: DeprecationWarning: urllib.parse.splitport() is deprecated as of 3.8, use urllib.parse.urlparse() instead host, port = urllib.splitport(host)
1 parent d26cf9d commit de5e719

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

supervisor/http.py

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

15-
from supervisor.compat import urllib
1615
from supervisor.compat import sha1
1716
from supervisor.compat import as_bytes
1817
from supervisor.compat import as_string
18+
from supervisor.compat import urlparse
19+
1920
from supervisor.medusa import asyncore_25 as asyncore
2021
from supervisor.medusa import http_date
2122
from supervisor.medusa import http_server
@@ -315,7 +316,8 @@ def get_server_url(self):
315316

316317
if 'HTTP_HOST' in environ:
317318
host = environ['HTTP_HOST'].strip()
318-
hostname, port = urllib.splitport(host)
319+
parsed = urlparse.urlparse(host)
320+
hostname, port = parsed.hostname, str(parsed.port)
319321
else:
320322
hostname = environ['SERVER_NAME'].strip()
321323
port = environ['SERVER_PORT']

supervisor/xmlrpc.py

Lines changed: 3 additions & 6 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
1312
from supervisor.compat import as_bytes
1413
from supervisor.compat import as_string
1514
from supervisor.compat import encodestring
1615
from supervisor.compat import decodestring
1716
from supervisor.compat import httplib
1817
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,13 +486,10 @@ def __init__(self, username=None, password=None, serverurl=None):
486486
self.verbose = False
487487
self.serverurl = serverurl
488488
if serverurl.startswith('http://'):
489-
type, uri = urllib.splittype(serverurl)
490-
host, path = urllib.splithost(uri)
491-
host, port = urllib.splitport(host)
489+
parsed = urlparse.urlparse(serverurl)
490+
host, port = parsed.hostname, parsed.port
492491
if port is None:
493492
port = 80
494-
else:
495-
port = int(port)
496493
def get_connection(host=host, port=port):
497494
return httplib.HTTPConnection(host, port)
498495
self._get_connection = get_connection

0 commit comments

Comments
 (0)