forked from M-Labs/artiq
1
0
Fork 0

bit2bin: close input file explicitly

This commit is contained in:
Sebastien Bourdeauducq 2016-05-21 21:50:08 +08:00
parent 65c835e991
commit 852ddb7796
1 changed files with 29 additions and 30 deletions

View File

@ -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")