Forced utf-8 encoding when loading common passwords in CommonPasswordValidator.

Previously we used `decode()` which defaults to utf-8. This change
restores previous behavior.

Follow up to 28eac41510.
This commit is contained in:
Mariusz Felisiak 2019-05-23 08:39:16 +02:00 committed by GitHub
parent a2c31e12da
commit 2007e11d70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -171,7 +171,7 @@ class CommonPasswordValidator:
def __init__(self, password_list_path=DEFAULT_PASSWORD_LIST_PATH): def __init__(self, password_list_path=DEFAULT_PASSWORD_LIST_PATH):
try: try:
with gzip.open(password_list_path, 'rt') as f: with gzip.open(password_list_path, 'rt', encoding='utf-8') as f:
self.passwords = {x.strip() for x in f} self.passwords = {x.strip() for x in f}
except OSError: except OSError:
with open(password_list_path) as f: with open(password_list_path) as f: