From 30c4fb55e91aa879bb9e4f7382ba87565d9f5c58 Mon Sep 17 00:00:00 2001 From: Artur Mullakhmetov Date: Fri, 27 Jan 2017 11:33:27 +0300 Subject: [PATCH] Added context manager to file reading old-commit-hash: 48f203ad5b5f83e53d140d6c36b1ef6637fa9c6c --- common/dbc.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/dbc.py b/common/dbc.py index 4414b79839..d333f0a917 100755 --- a/common/dbc.py +++ b/common/dbc.py @@ -16,7 +16,8 @@ DBCSignal = namedtuple( class dbc(object): def __init__(self, fn): - self.txt = open(fn).read().split("\n") + with open(fn) as f: + self.txt = f.read().split("\n") self._warned_addresses = set() # regexps from https://github.com/ebroecker/canmatrix/blob/master/canmatrix/importdbc.py