mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-24 12:05:22 +08:00
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
This commit is contained in:
parent
ceaf1c1158
commit
1901eeac63
@ -35,7 +35,7 @@ from notebook._sysinfo import get_sys_info
|
||||
|
||||
from traitlets.config import Application
|
||||
from ipython_genutils.path import filefind
|
||||
from ipython_genutils.py3compat import string_types
|
||||
from ipython_genutils.py3compat import string_types, PY3
|
||||
|
||||
import notebook
|
||||
from notebook._tz import utcnow
|
||||
@ -427,6 +427,10 @@ class IPythonHandler(AuthenticatedHandler):
|
||||
if host.startswith('[') and host.endswith(']'):
|
||||
host = host[1:-1]
|
||||
|
||||
if not PY3:
|
||||
# ip_address only accepts unicode on Python 2
|
||||
host = host.decode('utf8', 'replace')
|
||||
|
||||
try:
|
||||
addr = ipaddress.ip_address(host)
|
||||
except ValueError:
|
||||
|
Loading…
Reference in New Issue
Block a user