• Bug#1064961: apt-xapian-index: fails with Python 3.12

    From Graham Inggs@21:1/5 to All on Wed Feb 28 14:10:02 2024
    Package: src:apt-xapian-index
    Version: 0.54
    Severity: important
    Tags: patch
    User: debian-python@lists.debian.org
    Usertags: python3.12

    Hi Maintainer

    apt-xapian-index fails when Python 3.12 is the default.

    $ axi-cache info
    Traceback (most recent call last):
    File "/usr/bin/axi-cache", line 864, in <module>
    sys.exit(ui.perform())
    ^^^^^^^^^^^^
    File "/usr/bin/axi-cache", line 855, in perform
    return f(self.args)
    ^^^^^^^^^^^^
    File "/usr/bin/axi-cache", line 411, in do_info
    import axi.indexer
    File "/usr/lib/python3/dist-packages/axi/indexer.py", line 27, in <module>
    import imp
    ModuleNotFoundError: No module named 'imp'

    The patch below was applied in Ubuntu.

    Regards
    Graham


    --- a/axi/indexer.py
    +++ b/axi/indexer.py
    @@ -23,7 +23,7 @@
    import axi
    import sys
    import os
    -import imp
    +from importlib.machinery import SourceFileLoader
    import socket, errno
    import fcntl
    import textwrap
    @@ -59,7 +59,7 @@
    oldpath = sys.path
    try:
    sys.path.append(os.path.dirname(fname))
    - self.module = imp.load_source("axi.plugin_" + self.name, fname)
    + self.module = SourceFileLoader("axi.plugin_" + self.name, fname).load_module()
    finally:
    sys.path = oldpath
    try:

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)