Workaround python returning bytes based filenames on some windows systems

This commit is contained in:
Kovid Goyal 2023-10-23 08:00:57 +05:30
parent 506022b5aa
commit fb5e14046c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -11,7 +11,7 @@ import tempfile
from functools import partial
from urllib.parse import quote
from calibre.constants import isbsd, islinux
from calibre.constants import isbsd, islinux, filesystem_encoding
from calibre.customize.conversion import InputFormatPlugin, OptionRecommendation
from calibre.utils.filenames import ascii_filename, get_long_path_name
from calibre.utils.imghdr import what
@ -88,8 +88,11 @@ class HTMLInput(InputFormatPlugin):
fname = None
if hasattr(stream, 'name'):
basedir = os.path.dirname(stream.name)
fname = os.path.basename(stream.name)
sname = stream.name
if isinstance(sname, bytes):
sname = sname.decode(filesystem_encoding)
basedir = os.path.dirname(sname)
fname = os.path.basename(sname)
self.set_root_dir_of_input(basedir)
if file_ext != 'opf':