Skip to content

Commit

Permalink
check if module existed
Browse files Browse the repository at this point in the history
  • Loading branch information
mdrachuk committed Aug 22, 2019
1 parent a62471d commit d8b50c1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cv.py
Expand Up @@ -79,10 +79,10 @@ def _parse_args(args: List[str]):
def _resolve_module(module_name: str):
"""Black magic. Prevents loading a package from cv dependencies."""
invalidate_caches()
old_module = sys.modules.get(module_name, None)
del sys.modules[module_name]
old_module = sys.modules.pop(module_name, None)
module = import_module(module_name)
sys.modules[module_name] = old_module
if old_module:
sys.modules[module_name] = old_module
return module


Expand Down

0 comments on commit d8b50c1

Please sign in to comment.