From b711eafd2aabdf22e1d529bfb76dd8d3356d7000 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Wed, 22 May 2019 10:47:29 -0700 Subject: [PATCH] Refs #30116 -- Removed unnecessary str() calls in CommonPasswordValidator. open() and gzip.open() supports path-like objects since Python 3.6. --- django/contrib/auth/password_validation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/django/contrib/auth/password_validation.py b/django/contrib/auth/password_validation.py index 2b43ed94245..bfdc096a9a0 100644 --- a/django/contrib/auth/password_validation.py +++ b/django/contrib/auth/password_validation.py @@ -171,10 +171,10 @@ class CommonPasswordValidator: def __init__(self, password_list_path=DEFAULT_PASSWORD_LIST_PATH): try: - with gzip.open(str(password_list_path), 'rt') as f: + with gzip.open(password_list_path, 'rt') as f: self.passwords = {x.strip() for x in f} except OSError: - with open(str(password_list_path)) as f: + with open(password_list_path) as f: self.passwords = {x.strip() for x in f} def validate(self, password, user=None):