From e9771cc83499b138d05efe1ae94d732f0f0c4eb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sun, 17 Nov 2019 10:29:35 +0100 Subject: [PATCH] storage: force (some) filename as bytes (#36515) (required for python 3.5) --- wcs/qommon/storage.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wcs/qommon/storage.py b/wcs/qommon/storage.py index dc2e6a4af..5670f5361 100644 --- a/wcs/qommon/storage.py +++ b/wcs/qommon/storage.py @@ -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: