Skip to content

Commit f16b073

Browse files
committed
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
1 parent 934e480 commit f16b073

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

notebook/notebookapp.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import datetime
1212
import errno
1313
import gettext
14+
import hashlib
15+
import hmac
1416
import importlib
1517
import io
1618
import json
@@ -27,7 +29,6 @@
2729
import time
2830
import warnings
2931
import webbrowser
30-
import hmac
3132

3233
try: #PY3
3334
from base64 import encodebytes
@@ -706,7 +707,7 @@ def _default_cookie_secret(self):
706707
else:
707708
key = encodebytes(os.urandom(32))
708709
self._write_cookie_secret_file(key)
709-
h = hmac.HMAC(key, digestmod='sha256')
710+
h = hmac.new(key, digestmod=hashlib.sha256)
710711
h.update(self.password.encode())
711712
return h.digest()
712713

0 commit comments

Comments
 (0)