Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #6256 : migrate to python 3.7+ #6260

Merged
merged 3 commits into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@
# -- Options for link checks ----------------------------------------------

linkcheck_ignore = [
'http://127\.0\.0\.1/*'
r'http://127\.0\.0\.1/*'
]


Expand Down
1 change: 0 additions & 1 deletion notebook/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

if __name__ == '__main__':
from notebook import notebookapp as app
app.launch_new_instance()
6 changes: 3 additions & 3 deletions notebook/_sysinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ def pkg_commit_hash(pkg_path):
if repo_commit:
return 'repository', repo_commit.strip().decode('ascii')
else:
return u'', u''
return '', ''
par_path = p.dirname(par_path)
return u'', u''

return '', ''


def pkg_info(pkg_path):
Expand Down
14 changes: 7 additions & 7 deletions notebook/auth/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ def hashed_password(self):

def passwd_check(self, a, b):
return passwd_check(a, b)

def post(self):
typed_password = self.get_argument('password', default=u'')
new_password = self.get_argument('new_password', default=u'')
typed_password = self.get_argument('password', default='')
new_password = self.get_argument('new_password', default='')




if self.get_login_available(self.settings):
if self.passwd_check(self.hashed_password, typed_password) and not new_password:
self.set_login_cookie(self, uuid.uuid4().hex)
Expand Down Expand Up @@ -112,7 +112,7 @@ def set_login_cookie(cls, handler, user_id=None):
handler.set_secure_cookie(handler.cookie_name, user_id, **cookie_options)
return user_id

auth_header_pat = re.compile('token\s+(.+)', re.IGNORECASE)
auth_header_pat = re.compile(r'token\s+(.+)', re.IGNORECASE)

@classmethod
def get_token(cls, handler):
Expand Down Expand Up @@ -197,7 +197,7 @@ def get_user(cls, handler):
@classmethod
def get_user_token(cls, handler):
"""Identify the user based on a token in the URL or Authorization header

Returns:
- uuid if authenticated
- None if not
Expand Down Expand Up @@ -245,7 +245,7 @@ def password_from_settings(cls, settings):

If there is no configured password, an empty string will be returned.
"""
return settings.get('password', u'')
return settings.get('password', '')

@classmethod
def get_login_available(cls, settings):
Expand Down
7 changes: 3 additions & 4 deletions notebook/auth/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from contextlib import contextmanager
import getpass
import hashlib
import io
import json
import os
import random
Expand Down Expand Up @@ -135,7 +134,7 @@ def passwd_check(hashed_passphrase, passphrase):
def persist_config(config_file=None, mode=0o600):
"""Context manager that can be used to modify a config object

On exit of the context manager, the config will be written back to disk,
On exit of the context manager, the config will be written back to disk,
by default with user-only (600) permissions.
"""

Expand All @@ -152,7 +151,7 @@ def persist_config(config_file=None, mode=0o600):

yield config

with io.open(config_file, 'w', encoding='utf8') as f:
with open(config_file, 'w', encoding='utf8') as f:
f.write(cast_unicode(json.dumps(config, indent=2)))

try:
Expand All @@ -165,7 +164,7 @@ def persist_config(config_file=None, mode=0o600):

def set_password(password=None, config_file=None):
"""Ask user for password, store it in notebook json configuration file"""

hashed_password = passwd(password)

with persist_config(config_file) as config:
Expand Down
10 changes: 5 additions & 5 deletions notebook/auth/tests/test_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def test_bad():

def test_passwd_check_unicode():
# GH issue #4524
phash = u'sha1:23862bc21dd3:7a415a95ae4580582e314072143d9c382c491e4f'
assert passwd_check(phash, u"łe¶ŧ←↓→")
phash = (u'argon2:$argon2id$v=19$m=10240,t=10,p=8$'
u'qjjDiZUofUVVnrVYxacnbA$l5pQq1bJ8zglGT2uXP6iOg')
assert passwd_check(phash, u"łe¶ŧ←↓→")
phash = 'sha1:23862bc21dd3:7a415a95ae4580582e314072143d9c382c491e4f'
assert passwd_check(phash, "łe¶ŧ←↓→")
phash = ('argon2:$argon2id$v=19$m=10240,t=10,p=8$'
'qjjDiZUofUVVnrVYxacnbA$l5pQq1bJ8zglGT2uXP6iOg')
assert passwd_check(phash, "łe¶ŧ←↓→")
Loading