summaryrefslogtreecommitdiff
path: root/src/werkzeug/utils.py
diff options
context:
space:
mode:
authorDavid Lord <davidism@gmail.com>2021-10-04 18:34:17 -0700
committerDavid Lord <davidism@gmail.com>2021-10-04 18:49:34 -0700
commit08a0ea55152503f7ee1be8f1513b56f2c9dd490b (patch)
treeedcc3ceeb019cae1e42e9bc00ebc20ea13135e1f /src/werkzeug/utils.py
parent366b2d97eb10d5e3c16c2a5c19892dce68322ca2 (diff)
downloadwerkzeug-08a0ea55152503f7ee1be8f1513b56f2c9dd490b.tar.gz
use exception chaining
fixes flake8-bugbear B904
Diffstat (limited to 'src/werkzeug/utils.py')
-rw-r--r--src/werkzeug/utils.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/werkzeug/utils.py b/src/werkzeug/utils.py
index d5e4a8e1..90072314 100644
--- a/src/werkzeug/utils.py
+++ b/src/werkzeug/utils.py
@@ -847,7 +847,7 @@ def send_from_directory(
raise NotFound()
except ValueError:
# path contains null byte on Python < 3.8
- raise NotFound()
+ raise NotFound() from None
return send_file(path, environ, **kwargs)
@@ -880,11 +880,13 @@ def import_string(import_name: str, silent: bool = False) -> t.Any:
try:
return getattr(module, obj_name)
except AttributeError as e:
- raise ImportError(e)
+ raise ImportError(e) from None
except ImportError as e:
if not silent:
- raise ImportStringError(import_name, e).with_traceback(sys.exc_info()[2])
+ raise ImportStringError(import_name, e).with_traceback(
+ sys.exc_info()[2]
+ ) from None
return None