Ensure filename is a string

This commit is contained in:
Andrew Murray 2021-09-01 10:15:57 +10:00
parent d788682afe
commit 9c5bad6f0a
2 changed files with 3 additions and 3 deletions

View File

@ -2189,7 +2189,7 @@ class Image:
filename = str(fp) filename = str(fp)
open_fp = True open_fp = True
elif isPath(fp): elif isPath(fp):
filename = fp filename = os.fsdecode(fp)
open_fp = True open_fp = True
elif fp == sys.stdout: elif fp == sys.stdout:
try: try:
@ -2209,7 +2209,7 @@ class Image:
preinit() preinit()
ext = os.fsdecode(os.path.splitext(filename)[1].lower()) ext = os.path.splitext(filename)[1].lower()
if not format: if not format:
if ext not in EXTENSION: if ext not in EXTENSION:

View File

@ -317,7 +317,7 @@ def _accept(prefix):
def _save(im, fp, filename): def _save(im, fp, filename):
if os.fsdecode(os.path.splitext(filename)[1]) == ".j2k": if filename.endswith(".j2k"):
kind = "j2k" kind = "j2k"
else: else:
kind = "jp2" kind = "jp2"