From 19d29f9c841403575cc9a649121244c8d6d62c5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Venegas=20Arrab=C3=A9?= Date: Thu, 30 Jul 2026 16:19:15 +0200 Subject: [PATCH] bit2fasm: close the temporary bits file before bitread writes it The temporary bits file was created with NamedTemporaryFile() and kept open while the bitread subprocess wrote to it by name. On Windows that is a sharing violation (the open handle blocks the child's write), so bit2fasm always failed there. Create the file with delete=False, close it immediately, and unlink it via the ExitStack instead. No behaviour change on POSIX beyond the file being closed while bitread runs. --- utils/bit2fasm.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/utils/bit2fasm.py b/utils/bit2fasm.py index 859ec109..464c3de1 100755 --- a/utils/bit2fasm.py +++ b/utils/bit2fasm.py @@ -108,7 +108,12 @@ def main(): if args.bits_file: bits_file = stack.enter_context(open(args.bits_file, 'wb')) else: - bits_file = stack.enter_context(tempfile.NamedTemporaryFile()) + # On Windows an open NamedTemporaryFile cannot be re-opened by + # the bitread subprocess (sharing violation): create it closed + # and clean it up ourselves. + bits_file = tempfile.NamedTemporaryFile(delete=False) + bits_file.close() + stack.callback(os.unlink, bits_file.name) bit_to_bits( bitread=args.bitread,