Fix smart/force_text to _str required by latest Django

This commit is contained in:
Griatch 2025-04-14 21:19:02 +02:00
parent 5b2963fc46
commit bfebb050da

View file

@ -76,7 +76,7 @@ from tempfile import SpooledTemporaryFile
from django.core.files.base import File
from django.core.files.storage import Storage
from django.utils.deconstruct import deconstructible
from django.utils.encoding import filepath_to_uri, force_bytes, force_text, smart_text
from django.utils.encoding import filepath_to_uri, force_bytes, force_str, smart_str
from django.utils.timezone import is_naive, make_naive
try:
@ -127,9 +127,9 @@ def safe_join(base, *paths):
final_path (str): A joined path, base + filepath
"""
base_path = force_text(base)
base_path = force_str(base)
base_path = base_path.rstrip("/")
paths = [force_text(p) for p in paths]
paths = [force_str(p) for p in paths]
final_path = base_path + "/"
for path in paths:
@ -252,7 +252,7 @@ class S3Boto3StorageFile(File):
self._storage = storage
self.name = name[len(self._storage.location) :].lstrip("/")
self._mode = mode
self._force_mode = (lambda b: b) if "b" in mode else force_text
self._force_mode = (lambda b: b) if "b" in mode else force_str
self.obj = storage.bucket.Object(storage._encode_name(name))
if "w" not in mode:
# Force early RAII-style exception if object does not exist
@ -632,10 +632,10 @@ class S3Boto3Storage(Storage):
raise SuspiciousOperation("Attempted access to '%s' denied." % name)
def _encode_name(self, name):
return smart_text(name, encoding=self.file_name_charset)
return smart_str(name, encoding=self.file_name_charset)
def _decode_name(self, name):
return force_text(name, encoding=self.file_name_charset)
return force_str(name, encoding=self.file_name_charset)
def _compress_content(self, content):
"""Gzip a given string content."""