Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions confuse/util.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import importlib.util
import os
import sys
import argparse
import optparse
import platform
import pkgutil


UNIX_DIR_FALLBACK = '~/.config'
Expand Down Expand Up @@ -114,8 +114,14 @@ def find_package_path(name):
None if the path could not be identified (e.g., if
``name == "__main__"``).
"""
# Based on get_root_path from Flask by Armin Ronacher.
loader = pkgutil.get_loader(name)
# Based on get_root_path from Flask by Armin Ronacher, cf.
# https://github.com/pallets/flask/blob/85c5d93cbd049c4bd0679c36fd1ddcae8c37b642/src/flask/helpers.py#L570
try:
spec = importlib.util.find_spec(name)
except (ImportError, ValueError):
return None

loader = spec.loader
if loader is None or name == '__main__':
return None

Expand Down