diff options
Diffstat (limited to 'qutebrowser/components')
-rw-r--r-- | qutebrowser/components/hostblock.py | 7 | ||||
-rw-r--r-- | qutebrowser/components/utils/blockutils.py | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/qutebrowser/components/hostblock.py b/qutebrowser/components/hostblock.py index 1860b734c..191719f10 100644 --- a/qutebrowser/components/hostblock.py +++ b/qutebrowser/components/hostblock.py @@ -64,9 +64,10 @@ def get_fileobj(byte_io: IO[bytes]) -> IO[bytes]: byte_io.seek(0) # rewind downloaded file if zipfile.is_zipfile(byte_io): byte_io.seek(0) # rewind what zipfile.is_zipfile did - zf = zipfile.ZipFile(byte_io) - filename = _guess_zip_filename(zf) - byte_io = zf.open(filename, mode="r") + with zipfile.ZipFile(byte_io) as zf: + filename = _guess_zip_filename(zf) + # pylint: disable=consider-using-with + byte_io = zf.open(filename, mode="r") else: byte_io.seek(0) # rewind what zipfile.is_zipfile did return byte_io diff --git a/qutebrowser/components/utils/blockutils.py b/qutebrowser/components/utils/blockutils.py index bd27baece..98681a488 100644 --- a/qutebrowser/components/utils/blockutils.py +++ b/qutebrowser/components/utils/blockutils.py @@ -125,7 +125,7 @@ class BlocklistDownloads(QObject): filename: path to a local file to import. """ try: - fileobj = open(filename, "rb") + fileobj = open(filename, "rb") # pylint: disable=consider-using-with except OSError as e: message.error( "blockutils: Error while reading {}: {}".format(filename, e.strerror) |