From 955e66c149a8df3a1af78d8766eb46b78af76a82 Mon Sep 17 00:00:00 2001 From: Vincent Post Date: Fri, 7 Aug 2020 18:16:57 +0200 Subject: 2to3: UTF-8 is now default in Python 3 --- accounts/backend/user/dummy.py | 3 --- accounts/default_settings.py | 2 +- accounts/models.py | 15 ++------------- accounts/utils/sessions.py | 2 +- 4 files changed, 4 insertions(+), 18 deletions(-) diff --git a/accounts/backend/user/dummy.py b/accounts/backend/user/dummy.py index 573ac85..c1dbcb4 100644 --- a/accounts/backend/user/dummy.py +++ b/accounts/backend/user/dummy.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- - - from copy import deepcopy from fnmatch import fnmatch diff --git a/accounts/default_settings.py b/accounts/default_settings.py index 25ff814..cf36c6c 100644 --- a/accounts/default_settings.py +++ b/accounts/default_settings.py @@ -5,7 +5,7 @@ DEBUG = False SECRET_KEY = 'remember to change this to something more random and secret' # CHANGE THIS! (e.g. os.urandom(32) ) -SESSION_ENCRYPTION_KEY = '.\x14\xa7\x1b\xa2:\x1b\xb7\xbck\x1bD w\xab\x87a\xb4\xb7\xca\xf1\x06\xb0\x9f?q\x13\x05\x8dY\xe5<' +SESSION_ENCRYPTION_KEY = b'.\x14\xa7\x1b\xa2:\x1b\xb7\xbck\x1bD w\xab\x87a\xb4\xb7\xca\xf1\x06\xb0\x9f?q\x13\x05\x8dY\xe5<' MAIL_DEFAULT_SENDER = 'spline accounts ' MAIL_REGISTER_NOTIFY = None diff --git a/accounts/models.py b/accounts/models.py index 40db977..aa0e4d0 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from flask.ext.login import UserMixin from accounts.utils.login import create_userid @@ -13,9 +11,9 @@ class Account(UserMixin): _ready = False def __init__(self, uid, mail, services=None, password=None, uidNumber=None): - self.uid = uid.encode('utf8') if isinstance(uid, str) else uid + self.uid = uid self.services = list() if services is None else services - self.password = password.encode('utf8') if isinstance(password, str) else password + self.password = password self.new_password_root = None self.new_password_services = {} self.attributes = {} @@ -37,21 +35,12 @@ class Account(UserMixin): the root password will be changed. """ - if isinstance(new_password, str): - new_password = new_password.encode('utf8') - - if isinstance(old_password, str): - old_password = old_password.encode('utf8') - if not service: self.new_password_root = (old_password, new_password) else: self.new_password_services[service] = (old_password, new_password) def _set_attribute(self, key, value): - if isinstance(value, str): - value = value.encode('utf8') - self.attributes[key] = value def change_email(self, new_mail): diff --git a/accounts/utils/sessions.py b/accounts/utils/sessions.py index 7b24f8a..1b4a168 100644 --- a/accounts/utils/sessions.py +++ b/accounts/utils/sessions.py @@ -10,7 +10,7 @@ from itsdangerous import BadPayload def _pad(value, block_size): padding = block_size - len(value) % block_size - return value + (padding * chr(padding)) + return (value + (padding * chr(padding))).encode("UTF-8") def _unpad(value): -- cgit v1.2.3-1-g7c22