forked from M-Labs/artiq
bit2bin: close input file explicitly
This commit is contained in:
parent
dfeff967ba
commit
9db9f4e624
|
@ -32,8 +32,7 @@ def flip32(data):
|
||||||
|
|
||||||
|
|
||||||
def bit2bin(bit, bin, flip=False):
|
def bit2bin(bit, bin, flip=False):
|
||||||
bitfile = open(bit, "rb")
|
with open(bit, "rb") as bitfile:
|
||||||
|
|
||||||
l, = struct.unpack(">H", bitfile.read(2))
|
l, = struct.unpack(">H", bitfile.read(2))
|
||||||
if l != 9:
|
if l != 9:
|
||||||
raise ValueError("Missing <0009> header, not a bit file")
|
raise ValueError("Missing <0009> header, not a bit file")
|
||||||
|
|
Loading…
Reference in New Issue