Skip to content

Commit 1901eea

Browse files
committed
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 ceaf1c1 commit 1901eea

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

notebook/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 notebook
4141
from notebook._tz import utcnow
@@ -427,6 +427,10 @@ def check_host(self):
427427
if host.startswith('[') and host.endswith(']'):
428428
host = host[1:-1]
429429

430+
if not PY3:
431+
# ip_address only accepts unicode on Python 2
432+
host = host.decode('utf8', 'replace')
433+
430434
try:
431435
addr = ipaddress.ip_address(host)
432436
except ValueError:

0 commit comments

Comments
 (0)