aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.com>2024-07-22 12:34:07 +0300
committershadchin <shadchin@yandex-team.com>2024-07-22 12:50:13 +0300
commit318302642ecb37d11b85879aafe7bb4f3ef34c29 (patch)
tree1fb1e4504ffe0eea73a0fa46c1c3947ae19837a6
parent4ba0330b6d471d5fc105af31c7a0dbf2a19c839b (diff)
downloadydb-318302642ecb37d11b85879aafe7bb4f3ef34c29.tar.gz
Fix templates (version 3)
49884b800436aef9e54029e6c50127a57b0b882c
-rw-r--r--contrib/python/Jinja2/py3/jinja2/loaders.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/contrib/python/Jinja2/py3/jinja2/loaders.py b/contrib/python/Jinja2/py3/jinja2/loaders.py
index c36ae77e15..24951c35d2 100644
--- a/contrib/python/Jinja2/py3/jinja2/loaders.py
+++ b/contrib/python/Jinja2/py3/jinja2/loaders.py
@@ -296,7 +296,13 @@ class PackageLoader(BaseLoader):
# Make sure the package exists. This also makes namespace
# packages work, otherwise get_loader returns None.
- package = import_module(package_name)
+ try:
+ package = import_module(package_name)
+ except ModuleNotFoundError:
+ if skip_unknown_package:
+ self._template_root = None
+ return
+ raise
spec = importlib.util.find_spec(package_name)
assert spec is not None, "An import spec was not found for the package."
loader = spec.loader
@@ -330,7 +336,7 @@ class PackageLoader(BaseLoader):
template_root = root
break
- if template_root is None and not skip_unknown_package:
+ if template_root is None:
raise ValueError(
f"The {package_name!r} package was not installed in a"
" way that PackageLoader understands."