Skip to content

Commit 770cc10

Browse files
authored
Get rid of names_digest hack no longer needed (#14459)
1 parent 159dd62 commit 770cc10

File tree

2 files changed

+3
-34
lines changed

2 files changed

+3
-34
lines changed

awx/__init__.py

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -52,39 +52,14 @@ def version_file():
5252
except ImportError: # pragma: no cover
5353
MODE = 'production'
5454

55-
import hashlib
5655

5756
try:
5857
import django # noqa: F401
59-
60-
HAS_DJANGO = True
6158
except ImportError:
62-
HAS_DJANGO = False
59+
pass
6360
else:
64-
from django.db.backends.base import schema
65-
from django.db.models import indexes
66-
from django.db.backends.utils import names_digest
6761
from django.db import connection
6862

69-
if HAS_DJANGO is True:
70-
# See upgrade blocker note in requirements/README.md
71-
try:
72-
names_digest('foo', 'bar', 'baz', length=8)
73-
except ValueError:
74-
75-
def names_digest(*args, length):
76-
"""
77-
Generate a 32-bit digest of a set of arguments that can be used to shorten
78-
identifying names. Support for use in FIPS environments.
79-
"""
80-
h = hashlib.md5(usedforsecurity=False)
81-
for arg in args:
82-
h.update(arg.encode())
83-
return h.hexdigest()[:length]
84-
85-
schema.names_digest = names_digest
86-
indexes.names_digest = names_digest
87-
8863

8964
def find_commands(management_dir):
9065
# Modified version of function from django/core/management/__init__.py.

requirements/README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,8 @@ for instructions.
5959

6060
If operating in a FIPS environment, `hashlib.md5()` will raise a `ValueError`,
6161
but will support the `usedforsecurity` keyword on RHEL and Centos systems.
62-
63-
Keep an eye on https://code.djangoproject.com/ticket/28401
64-
65-
The override of `names_digest` could easily be broken in a future version.
66-
Check that the import remains the same in the desired version.
67-
68-
https://github.com/django/django/blob/af5ec222ccd24e81f9fec6c34836a4e503e7ccf7/django/db/backends/base/schema.py#L7
62+
This used to be a problem with `names_digest` function in Django, but
63+
was fixed upstream in Django 4.1.
6964

7065
### django-split-settings
7166

@@ -172,4 +167,3 @@ available on PyPi with source distribution.
172167

173168
Version 4.8 makes us a little bit nervous with changes to `searchwindowsize` https://github.com/pexpect/pexpect/pull/579/files
174169
Pin to `pexpect==4.7.x` until we have more time to move to `4.8` and test.
175-

0 commit comments

Comments
 (0)