From ef0f46a1c94078474d80fb1f26551746aa393f4f Mon Sep 17 00:00:00 2001 From: Tino Wagner Date: Thu, 20 Jun 2024 13:13:39 +0200 Subject: [PATCH] Fix deprecation warning when importing a schema `load_module` has been deprecated since Python 3.4. A warning is issued in recent releases: > ImportWarning: _Loader.exec_module() not found; falling back to load_module() See: https://docs.python.org/3/library/importlib.html#importlib.abc.Loader.load_module --- capnp/lib/capnp.pyx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/capnp/lib/capnp.pyx b/capnp/lib/capnp.pyx index ef88f7c..4bcf201 100644 --- a/capnp/lib/capnp.pyx +++ b/capnp/lib/capnp.pyx @@ -4421,16 +4421,14 @@ class _Loader: self.fullname = fullname self.path = path - def load_module(self, fullname): - assert self.fullname == fullname, ( - "invalid module, expected {}, got {}".format(self.fullname, fullname)) - + def create_module(self, _spec): imports = _capnp_paths + [path if path != '' else '.' for path in _sys.path] - module = load(self.path, fullname, imports=imports) - _sys.modules[fullname] = module - + module = load(self.path, self.fullname, imports=imports) return module + def exec_module(self, _module): + pass + class _Importer: