Skip to content

Commit a56dde5

Browse files
committed
fixed find_module error for python 3.7 or newer
1 parent ac97c66 commit a56dde5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pymode/libs/pkg_resources/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2170,7 +2170,16 @@ def _handle_ns(packageName, path_item):
21702170
return None
21712171

21722172
if PY3:
2173-
loader = importer.find_module(packageName)
2173+
# * since python 3.3, the `imp.find_module()` is deprecated
2174+
# * `importlib.util.find_spec()` is new in python 3.4
2175+
# * in vim source, if compiled vim with python 3.7 or new, the vim
2176+
# python 3 interface will use `find_spec` instead of `find_module`
2177+
# and `load_module`. (note: this depends on the python which compiled
2178+
# with vim, not the python loaded by vim at runtime.)
2179+
try:
2180+
loader = importer.find_spec(packageName)
2181+
except AttributeError:
2182+
loader = importer.find_module(packageName)
21742183
else:
21752184
try:
21762185
loader = importer.find_module(packageName)

0 commit comments

Comments
 (0)