Skip to content

Commit

Permalink
Merge pull request #448 from edouardtheron/fix-deprecation-warning
Browse files Browse the repository at this point in the history
Use 'force_str' instead of deprecated 'force_text'
  • Loading branch information
Koed00 committed Jun 17, 2020
2 parents 22dc790 + dfea90f commit 58d71da
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions django_q/core_signing.py
Expand Up @@ -6,7 +6,7 @@
Signer as Sgnr, TimestampSigner as TsS, dumps
from django.utils import baseconv
from django.utils.crypto import constant_time_compare
from django.utils.encoding import force_bytes, force_str, force_text
from django.utils.encoding import force_bytes, force_str

dumps = dumps

Expand Down Expand Up @@ -39,14 +39,12 @@ def loads(s, key=None, salt='django.core.signing', serializer=JSONSerializer, ma
class Signer(Sgnr):

def unsign(self, signed_value):
# force_str is removed in Django 2.0
signed_value = force_str(signed_value)
if self.sep not in signed_value:
raise BadSignature('No "%s" found in value' % self.sep)
value, sig = signed_value.rsplit(self.sep, 1)
if constant_time_compare(sig, self.signature(value)):
# force_text is removed in Django 2.0
return force_text(value)
return force_str(value)
raise BadSignature('Signature "%s" does not match' % sig)


Expand Down

0 comments on commit 58d71da

Please sign in to comment.