Bug 1215851 - code generated by swig < 4.0.0 is incompatible with Python 3.12
Summary: code generated by swig < 4.0.0 is incompatible with Python 3.12
Status: IN_PROGRESS
Alias: None
Product: openSUSE Distribution
Classification: openSUSE
Component: Python (show other bugs)
Version: Leap 15.5
Hardware: Other Other
: P5 - None : Normal (vote)
Target Milestone: ---
Assignee: Klaus Kämpf
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-10-01 17:30 UTC by Matej Cepl
Modified: 2023-10-11 13:40 UTC (History)
4 users (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---
kkaempf: needinfo? (mcepl)


Attachments
_log.txt (155.54 KB, text/plain)
2023-10-01 17:30 UTC, Matej Cepl
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matej Cepl 2023-10-01 17:30: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.
Comment 1 Klaus Kämpf 2023-10-02 09:34:47 UTC
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 ...
Comment 2 Markéta Machová 2023-10-03 10:19:22 UTC
@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?
Comment 3 Steve Kowalik 2023-10-04 04:27:57 UTC
importlib does not have the same API as imp, so I'm against that idea. I'm still thinking how best to approach it.
Comment 4 Klaus Kämpf 2023-10-11 13:40:28 UTC
https://github.com/swig/swig/issues/2683 !