Skip to content

Commit 8df2861

Browse files
committed
hamster wheel: types.ModuleType() instead of module_from_spec()
Based on the python3 docs for imp.new_module(), I blindly transliterated imp.new_module() to importlib.util.module_from_spec(). But that doesn't work. ref: https://stackoverflow.com/a/32175781
1 parent a29f34e commit 8df2861

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pynvim/plugin/script_host.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Legacy python/python3-vim emulation."""
22
try:
3+
import types
34
import importlib
45
except ImportError:
56
import imp
@@ -41,7 +42,7 @@ def __init__(self, nvim):
4142
self.setup(nvim)
4243
# context where all code will run
4344
if IS_PYTHON3_7:
44-
self.module = importlib.util.module_from_spec('__main__')
45+
self.module = types.ModuleType('__main__')
4546
else:
4647
self.module = imp.new_module('__main__')
4748
nvim.script_context = self.module

0 commit comments

Comments
 (0)