# HG changeset patch # User Mads Kiilerich # Date 2019-12-27 01:02:20 # Node ID 88e0d0c0c208edaef6a1472c63230cfb48754f65 # Parent 45bfab30d433b62c62a9adb719f8b0d3ae536edf validator: fix ASCII password check to verify if it can be *encoded* in ascii In Python 2, unicode strings have a .decode method (which really doesn't make sense). Python 3 has more strict typing by design, and unicode strings don't have a .decode method. A Unicode string "is ASCII" if it can be encoded as ASCII. The check should thus *encode* to ASCII - not decode. diff --git a/kallithea/model/validators.py b/kallithea/model/validators.py --- a/kallithea/model/validators.py +++ b/kallithea/model/validators.py @@ -235,7 +235,7 @@ def ValidPassword(): def _validate_python(self, value, state): try: - (value or '').decode('ascii') + (value or '').encode('ascii') except UnicodeError: msg = self.message('invalid_password', state) raise formencode.Invalid(msg, value, state,)