From 2be45260147f517c3a53a3016cc3b7ae2367a04f Mon Sep 17 00:00:00 2001 From: Omer Katz Date: Sun, 21 Sep 2014 15:06:02 +0300 Subject: [PATCH 1/3] Python 3 compatability. --- zxcvbn/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zxcvbn/__init__.py b/zxcvbn/__init__.py index 7b444a4..19a64a7 100644 --- a/zxcvbn/__init__.py +++ b/zxcvbn/__init__.py @@ -11,8 +11,8 @@ for line in fileinput.input(): pw = line.strip() - print "Password: " + pw + print("Password: " + pw) out = password_strength(pw) for key, value in out.iteritems(): if key not in ignored: - print "\t%s: %s" % (key, value) + print("\t%s: %s" % (key, value)) From 79435b229d6933f8223896636d406f3c75c0e08f Mon Sep 17 00:00:00 2001 From: Omer Katz Date: Sun, 21 Sep 2014 17:25:12 +0300 Subject: [PATCH 2/3] Force resource string to be a string. --- zxcvbn/matching.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zxcvbn/matching.py b/zxcvbn/matching.py index a5b31a8..032f7a5 100644 --- a/zxcvbn/matching.py +++ b/zxcvbn/matching.py @@ -63,7 +63,7 @@ def _build_ranked_dict(unranked_list): def _load_frequency_lists(): - data = pkg_resources.resource_string(__name__, 'generated/frequency_lists.json') + data = str(pkg_resources.resource_string(__name__, 'generated/frequency_lists.json')) dicts = json.loads(data) for name, wordlist in dicts.items(): DICTIONARY_MATCHERS.append(_build_dict_matcher(name, _build_ranked_dict(wordlist))) @@ -71,7 +71,7 @@ def _load_frequency_lists(): def _load_adjacency_graphs(): global GRAPHS - data = pkg_resources.resource_string(__name__, 'generated/adjacency_graphs.json') + data = str(pkg_resources.resource_string(__name__, 'generated/adjacency_graphs.json')) GRAPHS = json.loads(data) From b20e04115cf6a15e75a7b70869d49ab87c8b94b0 Mon Sep 17 00:00:00 2001 From: Omer Katz Date: Sun, 21 Sep 2014 17:28:58 +0300 Subject: [PATCH 3/3] decode as utf8 --- zxcvbn/matching.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zxcvbn/matching.py b/zxcvbn/matching.py index 032f7a5..495e94b 100644 --- a/zxcvbn/matching.py +++ b/zxcvbn/matching.py @@ -63,7 +63,7 @@ def _build_ranked_dict(unranked_list): def _load_frequency_lists(): - data = str(pkg_resources.resource_string(__name__, 'generated/frequency_lists.json')) + data = pkg_resources.resource_string(__name__, 'generated/frequency_lists.json').decode("utf-8") dicts = json.loads(data) for name, wordlist in dicts.items(): DICTIONARY_MATCHERS.append(_build_dict_matcher(name, _build_ranked_dict(wordlist))) @@ -71,7 +71,7 @@ def _load_frequency_lists(): def _load_adjacency_graphs(): global GRAPHS - data = str(pkg_resources.resource_string(__name__, 'generated/adjacency_graphs.json')) + data = pkg_resources.resource_string(__name__, 'generated/adjacency_graphs.json').decode("utf-8") GRAPHS = json.loads(data)