cffi tests fail with Python 3.12 (uses removed `imp` module)
When running tests with Python 3.12.0b1, I get the following:
ImportError while importing test module '/var/tmp/portage/dev-python/cffi-1.15.1-r2/work/cffi-1.15.1/testing/cffi0/test_zdistutils.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.12/site-packages/_pytest/python.py:617: in _importtestmodule
mod = import_path(self.path, mode=importmode, root=self.config.rootpath)
/usr/lib/python3.12/site-packages/_pytest/pathlib.py:564: in import_path
importlib.import_module(module_name)
/usr/lib/python3.12/importlib/__init__.py:90: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1293: in _gcd_import
???
<frozen importlib._bootstrap>:1266: in _find_and_load
???
<frozen importlib._bootstrap>:1237: in _find_and_load_unlocked
???
<frozen importlib._bootstrap>:841: in _load_unlocked
???
/usr/lib/python3.12/site-packages/_pytest/assertion/rewrite.py:172: in exec_module
exec(co, module.__dict__)
testing/cffi0/test_zdistutils.py:1: in <module>
import sys, os, imp, math, shutil
E ModuleNotFoundError: No module named 'imp'
The imp
module has been removed in Python 3.12 and it's suggested that usage is ported to importlib
.