Skip to content

Commit

Permalink
adding more explicit exception catching
Browse files Browse the repository at this point in the history
Adjusting a series of exception catches to explicitly capture the
intended exceptions, respectively (to avoid masking other potential
issues).

Signed-off-by: James Knight <james.d.knight@live.com>
  • Loading branch information
jdknight committed Sep 28, 2020
1 parent 4b8413d commit 3954dc3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions releng_tool/util/io.py
Expand Up @@ -589,7 +589,7 @@ def _path_move(src, dst):
st = os.stat(src)
if not (st.st_mode & stat.S_IRUSR) or not (st.st_mode & stat.S_IWUSR):
os.chmod(src, st.st_mode | stat.S_IRUSR | stat.S_IWUSR)
except:
except OSError:
pass

entries = os.listdir(src)
Expand Down Expand Up @@ -683,7 +683,7 @@ def _path_remove_dir(dir_):
st = os.stat(dir_)
if not (st.st_mode & stat.S_IRUSR) or not (st.st_mode & stat.S_IWUSR):
os.chmod(dir_, st.st_mode | stat.S_IRUSR | stat.S_IWUSR)
except:
except OSError:
pass

# remove directory contents (if any)
Expand Down Expand Up @@ -733,7 +733,7 @@ def _path_remove_file(path):

os.chmod(path, st.st_mode | stat.S_IWUSR)
os.remove(path)
except:
except OSError:
raise e

def prepare_arguments(args):
Expand Down Expand Up @@ -899,5 +899,5 @@ def touch(file):
with open(file, 'a'):
os.utime(file, None)
return True
except:
except OSError:
return False

0 comments on commit 3954dc3

Please sign in to comment.