Skip to content

Commit 349045e

Browse files
minrkZsailer
authored andcommitted
ip_address only accepts unicode on Python 2
ipaddress.ip_address('127.0.0.1') fails with ValueError on Python 2 need to decode it, otherwise 127.0.0.1 won't be treated as local
1 parent cd79a98 commit 349045e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

jupyter_server/base/handlers.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
from traitlets.config import Application
3737
from ipython_genutils.path import filefind
38-
from ipython_genutils.py3compat import string_types
38+
from ipython_genutils.py3compat import string_types, PY3
3939

4040
import jupyter_server
4141
from jupyter_server._tz import utcnow
@@ -419,6 +419,10 @@ def check_host(self):
419419
if host.startswith('[') and host.endswith(']'):
420420
host = host[1:-1]
421421

422+
if not PY3:
423+
# ip_address only accepts unicode on Python 2
424+
host = host.decode('utf8', 'replace')
425+
422426
try:
423427
addr = ipaddress.ip_address(host)
424428
except ValueError:

0 commit comments

Comments
 (0)