From 76e1cd0f4b15a2fde268640835afd4e18c2b134c Mon Sep 17 00:00:00 2001 From: probonopd Date: Sun, 6 Aug 2017 23:40:28 +0200 Subject: [PATCH] Update worker.py --- code/worker.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/worker.py b/code/worker.py index 62cc1831..378e70ab 100644 --- a/code/worker.py +++ b/code/worker.py @@ -18,11 +18,11 @@ filename = firstline.split('/')[-1].split('#')[0].split('?')[0] urllib.request.urlretrieve(firstline, filename) # Get the magic bytes -f = open(filename) -f.seek(8) -data = f.read(3) -for c in data: - print(c) # FIXME; should be 0x414902 +with open(filename) as f: # this always closes f, even if exceptions happen + f.seek(8) + data = f.read(3) + for c in data: + print(c) # FIXME; should be 0x414902 # Exit if the magic bytes are not 0x414901 (type 1) or 0x414902 (type 2)