mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Replaced many smart_bytes by force_bytes
In all those occurrences, we didn't care about preserving the lazy status of the strings, but we really wanted to obtain a real bytestring.
This commit is contained in:
4
django/core/cache/backends/db.py
vendored
4
django/core/cache/backends/db.py
vendored
@@ -12,7 +12,7 @@ from django.conf import settings
|
||||
from django.core.cache.backends.base import BaseCache
|
||||
from django.db import connections, router, transaction, DatabaseError
|
||||
from django.utils import timezone
|
||||
from django.utils.encoding import smart_bytes
|
||||
from django.utils.encoding import force_bytes
|
||||
|
||||
|
||||
class Options(object):
|
||||
@@ -73,7 +73,7 @@ class DatabaseCache(BaseDatabaseCache):
|
||||
transaction.commit_unless_managed(using=db)
|
||||
return default
|
||||
value = connections[db].ops.process_clob(row[1])
|
||||
return pickle.loads(base64.b64decode(smart_bytes(value)))
|
||||
return pickle.loads(base64.b64decode(force_bytes(value)))
|
||||
|
||||
def set(self, key, value, timeout=None, version=None):
|
||||
key = self.make_key(key, version=version)
|
||||
|
||||
4
django/core/cache/backends/filebased.py
vendored
4
django/core/cache/backends/filebased.py
vendored
@@ -10,7 +10,7 @@ except ImportError:
|
||||
import pickle
|
||||
|
||||
from django.core.cache.backends.base import BaseCache
|
||||
from django.utils.encoding import smart_bytes
|
||||
from django.utils.encoding import force_bytes
|
||||
|
||||
class FileBasedCache(BaseCache):
|
||||
def __init__(self, dir, params):
|
||||
@@ -137,7 +137,7 @@ class FileBasedCache(BaseCache):
|
||||
Thus, a cache key of "foo" gets turnned into a file named
|
||||
``{cache-dir}ac/bd/18db4cc2f85cedef654fccc4a4d8``.
|
||||
"""
|
||||
path = hashlib.md5(smart_bytes(key)).hexdigest()
|
||||
path = hashlib.md5(force_bytes(key)).hexdigest()
|
||||
path = os.path.join(path[:2], path[2:4], path[4:])
|
||||
return os.path.join(self._dir, path)
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ from __future__ import unicode_literals
|
||||
import os
|
||||
from io import BytesIO, UnsupportedOperation
|
||||
|
||||
from django.utils.encoding import smart_bytes, smart_text
|
||||
from django.utils.encoding import smart_text
|
||||
from django.core.files.utils import FileProxyMixin
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import json
|
||||
from django.core.serializers.base import DeserializationError
|
||||
from django.core.serializers.python import Serializer as PythonSerializer
|
||||
from django.core.serializers.python import Deserializer as PythonDeserializer
|
||||
from django.utils.encoding import smart_bytes
|
||||
from django.utils import six
|
||||
from django.utils.timezone import is_aware
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ from django.db import models
|
||||
from django.core.serializers.base import DeserializationError
|
||||
from django.core.serializers.python import Serializer as PythonSerializer
|
||||
from django.core.serializers.python import Deserializer as PythonDeserializer
|
||||
from django.utils.encoding import smart_bytes
|
||||
from django.utils import six
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user