Skip to content

Commit 84627bf

Browse files
committed
address deprecation of pkgutil.get_loader
Closes #165
1 parent 5001e18 commit 84627bf

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

confuse/util.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import importlib
12
import os
23
import sys
34
import argparse
@@ -115,7 +116,12 @@ def find_package_path(name):
115116
``name == "__main__"``).
116117
"""
117118
# Based on get_root_path from Flask by Armin Ronacher.
118-
loader = pkgutil.get_loader(name)
119+
try:
120+
spec = importlib.util.find_spec(name)
121+
except (ImportError, ValueError):
122+
return None
123+
124+
loader = spec.loader
119125
if loader is None or name == '__main__':
120126
return None
121127

0 commit comments

Comments
 (0)