Kelvin Wong committed 201e2af Draft

In Django 1.4, make_password encoded unicode to utf-8 strings using smart_str
before hashing. This was removed in Django 1.5

Dj1.5 raised an error:

UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-6: ordinal not in range(128)

More testing is def needed.

Comments (0)

Files changed (2)


-__version__ = '0.2.4'
+from __future__ import unicode_literals
+__version__ = '0.2.3'
 __all__ = ['hashers']


 """Create and store Scrypt message digests
+from __future__ import unicode_literals
 from django.contrib.auth.hashers import BasePasswordHasher, mask_hash
 from django.utils.datastructures import SortedDict
 from django.utils.crypto import constant_time_compare
                 return self.stripws(s)
-            return self.stripws(str(s))
+            if type(s) is unicode:
+                return self.stripws(s.encode('utf-8'))
+            else:
+                return self.stripws(str(s))
     EMPTY = ''
     WHITESPACE = re.compile(r'\s+')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.