Skip to content

Commit

Permalink
python2 requires digestmod to be the module
Browse files Browse the repository at this point in the history
rather than the module name as str

and use `hmac.new` API from the docs, rather than undocumented class constructor
  • Loading branch information
minrk committed Mar 5, 2018
1 parent e80ed0d commit 78dfc7a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions notebook/notebookapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import datetime
import errno
import gettext
import hashlib
import hmac
import importlib
import io
import json
Expand All @@ -27,7 +29,6 @@
import time
import warnings
import webbrowser
import hmac

try: #PY3
from base64 import encodebytes
Expand Down Expand Up @@ -706,7 +707,7 @@ def _default_cookie_secret(self):
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()

Expand Down

0 comments on commit 78dfc7a

Please sign in to comment.