33 lines
1.1 KiB
Diff
33 lines
1.1 KiB
Diff
diff --git a/comtypes/client/_generate.py b/comtypes/client/_generate.py
|
|
index 1d0a350..bb9e2cd 100644
|
|
--- a/comtypes/client/_generate.py
|
|
+++ b/comtypes/client/_generate.py
|
|
@@ -3,6 +3,7 @@
|
|
import sys
|
|
import comtypes.client
|
|
import comtypes.tools.codegenerator
|
|
+import importlib
|
|
|
|
import logging
|
|
logger = logging.getLogger(__name__)
|
|
@@ -143,6 +144,9 @@ def GetModule(tlib):
|
|
ofi = open(os.path.join(comtypes.client.gen_dir, modulename + ".py"), "w")
|
|
ofi.write(code)
|
|
ofi.close()
|
|
+ # clear the import cache to make sure Python sees newly created modules
|
|
+ if hasattr(importlib, "invalidate_caches"):
|
|
+ importlib.invalidate_caches()
|
|
return _my_import("comtypes.gen." + modulename)
|
|
|
|
def _CreateWrapper(tlib, pathname=None):
|
|
@@ -181,6 +185,9 @@ def _CreateWrapper(tlib, pathname=None):
|
|
setattr(comtypes.gen, modname, mod)
|
|
else:
|
|
ofi.close()
|
|
+ # clear the import cache to make sure Python sees newly created modules
|
|
+ if hasattr(importlib, "invalidate_caches"):
|
|
+ importlib.invalidate_caches()
|
|
mod = _my_import(fullname)
|
|
return mod
|
|
|