storage: force (some) filename as bytes (#36515)

(required for python 3.5)
This commit is contained in:
Frédéric Péters 2019-11-17 10:29:35 +01:00
parent a1414e1ebc
commit e9771cc834
1 changed files with 3 additions and 2 deletions

View File

@ -25,6 +25,7 @@ import sys
import tempfile
from django.utils import six
from django.utils.encoding import force_bytes
from django.utils.six.moves import _thread
from .vendor import locket
@ -310,7 +311,7 @@ class StorableObject(object):
@classmethod
def has_key(cls, id):
filename = os.path.join(cls.get_objects_dir(), fix_key(id))
return os.path.exists(filename)
return os.path.exists(force_bytes(filename, 'utf-8'))
@classmethod
def get_new_id(cls, create=False):
@ -400,7 +401,7 @@ class StorableObject(object):
@classmethod
def get_filename(cls, filename, ignore_errors=False, ignore_migration=False, **kwargs):
try:
fd = open(filename, 'rb')
fd = open(force_bytes(filename, 'utf-8'), 'rb')
o = cls.storage_load(fd, **kwargs)
except IOError:
if ignore_errors: