From b3983f5ef82b4b09f1699c0f518390639279cb2a Mon Sep 17 00:00:00 2001 From: Rusty Bird Date: Thu, 13 Sep 2018 19:46:45 +0000 Subject: [PATCH] 'except FileNotFoundError' instead of ENOENT check --- qubes/app.py | 5 ++--- qubes/vm/qubesvm.py | 8 ++------ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/qubes/app.py b/qubes/app.py index fe770fa1..36d1f6be 100644 --- a/qubes/app.py +++ b/qubes/app.py @@ -22,7 +22,6 @@ import collections import copy -import errno import functools import grp import itertools @@ -1008,8 +1007,8 @@ class Qubes(qubes.PropertyHolder): try: fd = os.open(self._store, os.O_RDWR | (os.O_CREAT * int(for_save))) - except OSError as e: - if not for_save and e.errno == errno.ENOENT: + except FileNotFoundError: + if not for_save: raise qubes.exc.QubesException( 'Qubes XML store {!r} is missing; ' 'use qubes-create tool'.format(self._store)) diff --git a/qubes/vm/qubesvm.py b/qubes/vm/qubesvm.py index 85272c8e..506cfe99 100644 --- a/qubes/vm/qubesvm.py +++ b/qubes/vm/qubesvm.py @@ -24,7 +24,6 @@ from __future__ import absolute_import import asyncio import base64 -import errno import grp import os import os.path @@ -1461,11 +1460,8 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM): try: # TODO: make it async? shutil.rmtree(self.dir_path) - except OSError as e: - if e.errno == errno.ENOENT: - pass - else: - raise + except FileNotFoundError: + pass yield from self.storage.remove() @asyncio.coroutine