Skip to content

Commit f8be5f5

Browse files
committed
Improve robustness in load_module by specifying Exception type
1 parent 965e17d commit f8be5f5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tensorflow_quantum/core/ops/load_module.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import types
1919
from distutils.sysconfig import get_python_lib
2020

21+
from tensorflow.python.framework import errors
2122
from tensorflow.python.framework import load_library
2223
from tensorflow.python.platform import resource_loader
2324

@@ -47,7 +48,7 @@ def _load(self):
4748
try:
4849
path = resource_loader.get_path_to_datafile(self._name)
4950
self._module = load_library.load_op_library(path)
50-
except:
51+
except (IOError, errors.NotFoundError):
5152
path = os.path.join(get_python_lib(),
5253
"tensorflow_quantum/core/ops", self._name)
5354
self._module = load_library.load_op_library(path)

0 commit comments

Comments
 (0)