Skip to content

Commit

Permalink
fix: close file gracefully in espsecure
Browse files Browse the repository at this point in the history
  • Loading branch information
gnought committed Jan 29, 2024
1 parent 96a5c21 commit 2381711
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion espsecure/__init__.py
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
import tempfile
import zlib
from collections import namedtuple
from io import IOBase

from cryptography import exceptions
from cryptography.hazmat.backends import default_backend
@@ -1802,8 +1803,11 @@ def main(custom_commandline=None):
finally:
for arg_name in vars(args):
obj = getattr(args, arg_name)
if isinstance(obj, OutFileType):
if isinstance(obj, (OutFileType, IOBase)):
obj.close()
elif isinstance(obj, list):
for f in [o for o in obj if isinstance(o, IOBase)]:
f.close()


def _main():

0 comments on commit 2381711

Please sign in to comment.