Created
March 4, 2013 16:24
-
-
Save nvie/5083455 to your computer and use it in GitHub Desktop.
The following code crashes when ran on Django==1.5, but it works fine on Django==1.4.3. (Both py27.)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python minimal_example.py | |
Traceback (most recent call last): | |
File "minimal_example.py", line 7, in <module> | |
s.sign('foo') | |
File "/Users/nvie/.virtualenvs/foo/lib/python2.7/site-packages/django/core/signing.py", line 175, in sign | |
return str('%s%s%s') % (value, self.sep, self.signature(value)) | |
File "/Users/nvie/.virtualenvs/foo/lib/python2.7/site-packages/django/core/signing.py", line 169, in signature | |
signature = base64_hmac(self.salt + 'signer', value, self.key) | |
File "/Users/nvie/.virtualenvs/foo/lib/python2.7/site-packages/django/core/signing.py", line 75, in base64_hmac | |
return b64_encode(salted_hmac(salt, value, key).digest()) | |
File "/Users/nvie/.virtualenvs/foo/lib/python2.7/site-packages/django/utils/crypto.py", line 48, in salted_hmac | |
key = hashlib.sha1((key_salt + secret).encode('utf-8')).digest() | |
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 0: ordinal not in range(128) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf import settings | |
from django.core.signing import Signer | |
settings.SECRET_KEY = b'\xe7' # binary key with non-ASCII chars | |
s = Signer() | |
print(s.sign('foo')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment