From cdded22d2442f1c0f2fed1ef7c5e3d5861693dda Mon Sep 17 00:00:00 2001 From: Sten Linnarsson Date: Sat, 29 Sep 2018 00:45:51 -0700 Subject: [PATCH] prevent accidental file creation --- loompy/loompy.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/loompy/loompy.py b/loompy/loompy.py index a4c483c..df7dd30 100755 --- a/loompy/loompy.py +++ b/loompy/loompy.py @@ -70,7 +70,8 @@ def __init__(self, filename: str, mode: str = 'r+', *, validate: bool = True, sp Returns: Nothing. """ - + if not os.path.exists(filename): + raise IOError(f"File '{filename}' not found") # make sure a valid mode was passed if mode != 'r+' and mode != 'r': raise ValueError("Mode must be either 'r' or 'r+'")