Skip to content

Commit 5e7bcae

Browse files
committed
--
1 parent 3adccbd commit 5e7bcae

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

python_toolbox/import_tools.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ def import_if_exists(module_name, silent_fail=False):
9696
if not package:
9797
assert silent_fail is True
9898
return None
99-
package_path = package.__path__
100-
if not exists(submodule_name, package_path):
99+
if not exists(submodule_name, package_name):
101100
if silent_fail is True:
102101
return None
103102
else: # silent_fail is False
@@ -112,7 +111,7 @@ def import_if_exists(module_name, silent_fail=False):
112111
return normal_import(module_name)
113112

114113

115-
def exists(module_name, path=None):
114+
def exists(module_name, package_name=None):
116115
'''
117116
Return whether a module by the name `module_name` exists.
118117
@@ -124,7 +123,7 @@ def exists(module_name, path=None):
124123
'''
125124
if '.' in module_name:
126125
raise NotImplementedError
127-
return bool(importlib.util.find_spec(module_name))
126+
return bool(importlib.util.find_spec(module_name, package_name))
128127

129128

130129
def _module_address_to_partial_path(module_address):

0 commit comments

Comments
 (0)