From 8608ff11f72933ef22146824c5ab106f4a78100a Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Tue, 30 Jun 2020 19:58:07 +0200 Subject: [PATCH] Fix #1507 (Password generation on python2 working again) --- cps/helper.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cps/helper.py b/cps/helper.py index 506613eb..48efc69b 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -466,7 +466,10 @@ def reset_password(user_id): def generate_random_password(): s = "abcdefghijklmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%&*()?" passlen = 8 - return "".join(s[c % len(s)] for c in os.urandom(passlen)) + if sys.version_info < (3, 0): + return "".join(s[ord(c) % len(s)] for c in os.urandom(passlen)) + else: + return "".join(s[c % len(s)] for c in os.urandom(passlen)) def uniq(input):