mirror of https://github.com/openXC7/prjxray.git
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.
This commit is contained in:
parent
6731005c1e
commit
19d29f9c84
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue