summaryrefslogtreecommitdiff
path: root/django/utils
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2021-01-13 22:33:42 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-01-14 17:50:04 +0100
commitbe6e46813010f47e3dec22dd8c360df2dcf53369 (patch)
tree91fbbe318edd44dbcf7fc241d827b8ab0477ac26 /django/utils
parentd992f4e3c29a81c956d3d616f0bc19701431b26e (diff)
Refs #31359 -- Made get_random_string()'s length argument required.
Per deprecation timeline.
Diffstat (limited to 'django/utils')
-rw-r--r--django/utils/crypto.py13
1 files changed, 1 insertions, 12 deletions
diff --git a/django/utils/crypto.py b/django/utils/crypto.py
index 4fb3a9da9d..9d76f950b2 100644
--- a/django/utils/crypto.py
+++ b/django/utils/crypto.py
@@ -4,10 +4,8 @@ Django's standard crypto functions and utilities.
import hashlib
import hmac
import secrets
-import warnings
from django.conf import settings
-from django.utils.deprecation import RemovedInDjango40Warning
from django.utils.encoding import force_bytes
@@ -46,13 +44,10 @@ def salted_hmac(key_salt, value, secret=None, *, algorithm='sha1'):
return hmac.new(key, msg=force_bytes(value), digestmod=hasher)
-NOT_PROVIDED = object() # RemovedInDjango40Warning.
RANDOM_STRING_CHARS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
-# RemovedInDjango40Warning: when the deprecation ends, replace with:
-# def get_random_string(length, allowed_chars=RANDOM_STRING_CHARS):
-def get_random_string(length=NOT_PROVIDED, allowed_chars=RANDOM_STRING_CHARS):
+def get_random_string(length, allowed_chars=RANDOM_STRING_CHARS):
"""
Return a securely generated random string.
@@ -63,12 +58,6 @@ def get_random_string(length=NOT_PROVIDED, allowed_chars=RANDOM_STRING_CHARS):
* length: 12, bit length =~ 71 bits
* length: 22, bit length =~ 131 bits
"""
- if length is NOT_PROVIDED:
- warnings.warn(
- 'Not providing a length argument is deprecated.',
- RemovedInDjango40Warning,
- )
- length = 12
return ''.join(secrets.choice(allowed_chars) for i in range(length))