Fix baseconv/base62 deprecation warning for Django 5.x (#34)

This commit is contained in:
Stan Triepels
2022-11-09 00:41:12 +01:00
committed by GitHub
parent 1764c5c8ae
commit 17205549eb
2 changed files with 8 additions and 3 deletions
+6 -2
View File
@@ -6,7 +6,11 @@ from django.core.signing import BadSignature, JSONSerializer, SignatureExpired
from django.core.signing import Signer as Sgnr
from django.core.signing import TimestampSigner as TsS
from django.core.signing import b64_decode, dumps
from django.utils import baseconv
try:
from django.core.signing import base62
except ImportError:
# For django < 4.0
from django.utils.baseconv import base62
from django.utils.crypto import constant_time_compare
from django.utils.encoding import force_bytes, force_str
@@ -69,7 +73,7 @@ class TimestampSigner(Signer, TsS):
"""
result = super(TimestampSigner, self).unsign(value)
value, timestamp = result.rsplit(self.sep, 1)
timestamp = baseconv.base62.decode(timestamp)
timestamp = base62.decode(timestamp)
if max_age is not None:
if isinstance(max_age, datetime.timedelta):
max_age = max_age.total_seconds()