Skip to content

Commit a515a26

Browse files
authored
Fix regression for input/output filename clashing
Fixes #408
1 parent becfab8 commit a515a26

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pytesseract/pytesseract.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class TesseractNotFoundError(EnvironmentError):
8989
def __init__(self):
9090
super().__init__(
9191
f"{tesseract_cmd} is not installed or it's not in your PATH."
92-
+ ' See README file for more information.',
92+
f' See README file for more information.',
9393
)
9494

9595

@@ -158,7 +158,7 @@ def get_errors(error_string):
158158

159159
def cleanup(temp_name):
160160
"""Tries to remove temp files by filename wildcard path."""
161-
for filename in iglob(temp_name + '*' if temp_name else temp_name):
161+
for filename in iglob(f'{temp_name}*' if temp_name else temp_name):
162162
try:
163163
remove(filename)
164164
except OSError as e:
@@ -195,7 +195,7 @@ def save(image):
195195
yield f.name, realpath(normpath(normcase(image)))
196196
return
197197
image, extension = prepare(image)
198-
input_file_name = f.name + extsep + extension
198+
input_file_name = f'{f.name}_input{extsep}{extension}'
199199
image.save(input_file_name, format=image.format)
200200
yield f.name, input_file_name
201201
finally:
@@ -286,7 +286,7 @@ def run_and_get_output(
286286
}
287287

288288
run_tesseract(**kwargs)
289-
filename = kwargs['output_filename_base'] + extsep + extension
289+
filename = f"{kwargs['output_filename_base']}{extsep}{extension}"
290290
with open(filename, 'rb') as output_file:
291291
if return_bytes:
292292
return output_file.read()

0 commit comments

Comments
 (0)