From f16b073394e06ebf1c754ce601b40da89baf0a0f Mon Sep 17 00:00:00 2001 From: Min RK Date: Tue, 6 Mar 2018 00:01:38 +0100 Subject: [PATCH] python2 requires digestmod to be the module rather than the module name as str and use `hmac.new` API from the docs, rather than undocumented class constructor --- notebook/notebookapp.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/notebook/notebookapp.py b/notebook/notebookapp.py index 1e8dccf3c..6f896c7ba 100755 --- a/notebook/notebookapp.py +++ b/notebook/notebookapp.py @@ -11,6 +11,8 @@ import binascii import datetime import errno import gettext +import hashlib +import hmac import importlib import io import json @@ -27,7 +29,6 @@ import threading import time import warnings import webbrowser -import hmac try: #PY3 from base64 import encodebytes @@ -706,7 +707,7 @@ class NotebookApp(JupyterApp): else: key = encodebytes(os.urandom(32)) self._write_cookie_secret_file(key) - h = hmac.HMAC(key, digestmod='sha256') + h = hmac.new(key, digestmod=hashlib.sha256) h.update(self.password.encode()) return h.digest()