storage: force (some) filename as bytes (#36515)
(required for python 3.5)
This commit is contained in:
parent
a1414e1ebc
commit
e9771cc834
|
@ -25,6 +25,7 @@ import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
|
from django.utils.encoding import force_bytes
|
||||||
from django.utils.six.moves import _thread
|
from django.utils.six.moves import _thread
|
||||||
|
|
||||||
from .vendor import locket
|
from .vendor import locket
|
||||||
|
@ -310,7 +311,7 @@ class StorableObject(object):
|
||||||
@classmethod
|
@classmethod
|
||||||
def has_key(cls, id):
|
def has_key(cls, id):
|
||||||
filename = os.path.join(cls.get_objects_dir(), fix_key(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
|
@classmethod
|
||||||
def get_new_id(cls, create=False):
|
def get_new_id(cls, create=False):
|
||||||
|
@ -400,7 +401,7 @@ class StorableObject(object):
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_filename(cls, filename, ignore_errors=False, ignore_migration=False, **kwargs):
|
def get_filename(cls, filename, ignore_errors=False, ignore_migration=False, **kwargs):
|
||||||
try:
|
try:
|
||||||
fd = open(filename, 'rb')
|
fd = open(force_bytes(filename, 'utf-8'), 'rb')
|
||||||
o = cls.storage_load(fd, **kwargs)
|
o = cls.storage_load(fd, **kwargs)
|
||||||
except IOError:
|
except IOError:
|
||||||
if ignore_errors:
|
if ignore_errors:
|
||||||
|
|
Loading…
Reference in New Issue