fix: 'load_module()' deprecated in Python 3.12
authorMichael Jeanson <mjeanson@efficios.com>
Thu, 14 Dec 2023 22:11:42 +0000 (17:11 -0500)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 15 Dec 2023 18:51:46 +0000 (13:51 -0500)
commit69666e08a7f6108d5d300c27fac32e71b197244b
tree485c91d1ddf1c5e8768bfcbcef0f722be3d9ed3b
parent27b0e85b66b4814957292ca620793a071b541aa9
fix: 'load_module()' deprecated in Python 3.12

Starting with Python 3.10 we get the following warning:

  <frozen importlib._bootstrap>:283: DeprecationWarning: the
  load_module() method is deprecated and slated for removal in
  Python 3.12; use exec_module() instead

Replace our use of 'load_module()' with the recommended [1] alternative
that includes 'module_from_spec()' introduced in Python 3.5. Since we
need to support Python 3.4, keep the original code with a version check.

[1] https://docs.python.org/3.12/library/importlib.html#importlib.machinery.SourceFileLoader.load_module

Change-Id: I77d14f14fcc39e0227baad959c3e211aba309a21
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11583
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
src/bindings/python/bt2/bt2/py_plugin.py
This page took 0.026154 seconds and 4 git commands to generate.