Skip to content

Commit 8398234

Browse files
committed
fix Python 3.12 and imp #390
1 parent 32c2a69 commit 8398234

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

ftplugin/org.vim

-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ for p in vim.eval("&runtimepath").split(','):
120120
from orgmode._vim import ORGMODE, insert_at_cursor, get_user_input, date_to_str
121121
ORGMODE.start()
122122

123-
from Date import Date
124123
import datetime
125124
EOF
126125

ftplugin/orgmode/_vim.py

+24-13
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77
TODO
88
"""
99

10-
import imp
10+
try:
11+
import importlib
12+
USE_DEPRECATED_IMP=False
13+
except:
14+
import imp
15+
USE_DEPRECATED_IMP=True
16+
1117
import re
1218
import sys
1319

@@ -327,21 +333,26 @@ def register_plugin(self, plugin):
327333
# actual plugin class
328334
_class = None
329335

330-
# locate module and initialize plugin class
331-
try:
332-
module = imp.find_module(plugin, orgmode.plugins.__path__)
333-
except ImportError as e:
334-
echom(u'Plugin not found: %s' % plugin)
335-
if self.debug:
336-
raise e
337-
return
336+
if USE_DEPRECATED_IMP:
337+
# locate module and initialize plugin class
338+
try:
339+
module = imp.find_module(plugin, orgmode.plugins.__path__)
340+
except ImportError as e:
341+
echom(u'Plugin not found: %s' % plugin)
342+
if self.debug:
343+
raise e
344+
return
338345

339-
if not module:
340-
echom(u'Plugin not found: %s' % plugin)
341-
return
346+
if not module:
347+
echom(u'Plugin not found: %s' % plugin)
348+
return
342349

343350
try:
344-
module = imp.load_module(plugin, *module)
351+
if USE_DEPRECATED_IMP:
352+
module = imp.load_module(plugin, *module)
353+
else:
354+
module = importlib.import_module(".plugins." + plugin, "orgmode")
355+
345356
if not hasattr(module, plugin):
346357
echoe(u'Unable to find plugin: %s' % plugin)
347358
if self.debug:

0 commit comments

Comments
 (0)