Use with instead of closing manually
This commit is contained in:
parent
47dbaac54f
commit
8bb2da3c37
@ -449,9 +449,8 @@ def process_single_item(
|
|||||||
file_removed = False
|
file_removed = False
|
||||||
try:
|
try:
|
||||||
if isinstance(item, bytes):
|
if isinstance(item, bytes):
|
||||||
tf = NamedTemporaryFile(prefix='stdin-image-data-', delete=False)
|
with NamedTemporaryFile(prefix='stdin-image-data-', delete=False) as tf:
|
||||||
tf.write(item)
|
tf.write(item)
|
||||||
tf.close()
|
|
||||||
item = tf.name
|
item = tf.name
|
||||||
is_tempfile = True
|
is_tempfile = True
|
||||||
if url_pat is not None and url_pat.match(item) is not None:
|
if url_pat is not None and url_pat.match(item) is not None:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user