Bugzilla – Bug 1215851
code generated by swig < 4.0.0 is incompatible with Python 3.12
Last modified: 2023-10-11 13:40:28 UTC
Created attachment 869858 [details] _log.txt Code generated by swig < 4.0.0 (all Leap and SLE) generates code importing `imp` module, which has been deprecated in 3.4 (i.e., in all our supported Pythons 3) and removed in 3.12.
We can push https://build.opensuse.org/package/show/devel:tools:building/swig to Leap 15 or try to remove the "import imp". However, I'm a Python illiterate ...
@kkaempf Hi, I think replacing `import imp` by `import importlib as imp` should fix the problem, it is only a bit dirty :) . The code would then work only on Python 3, if you want to keep it Python 2-compatible, you'll have to be more verbose: ``` try: import importlib as imp except ImportError: import imp ``` The same with possible occurences of `import * from imp` -> `import * from importlib` and variations. But as I said, it is a bit dirty. If there are no serious problems in pushing a new version to Leap, please go ahead and update. Matěj, do you want to add something?
importlib does not have the same API as imp, so I'm against that idea. I'm still thinking how best to approach it.
https://github.com/swig/swig/issues/2683 !