#1149335 python-kaptan: FTBFS against python 3.15rc2 ('SourceFileLoader' object has no attribute 'load_module')

#1149335#5
Date:
2026-09-29 13:39:28 UTC
From:
To:
Hi!

While rebuilding the python related packages against the Python 3.15rc2
version we found that python-kaptan fails to build from source:
https://debusine.debian.net/debian/r-python-python3.15/artifact/4856779/

 From the log, the error seems to be:

           if sys.version_info[0] == 3 and sys.version_info[1] > 2:  #
Python >= 3.3
               import importlib.machinery
               loader = importlib.machinery.SourceFileLoader('',
pathname)
   >           mod = loader.load_module(mod_name)
                     ^^^^^^^^^^^^^^^^^^
   E           AttributeError: 'SourceFileLoader' object has no attribute
'load_module'. Did you mean '.exec_module' instead of '.load_module'?

This is because load_module is no longer supported. From
https://docs.python.org/3.15/whatsnew/3.15.html:

The load_module() methods of Loader and its subclasses is removed. The
import system will no longer call it when defined on custom subclasses.
The method has been deprecated in favor of exec_module() since Python
3.4. (Contributed by Brett Cannon in gh-97850.)

Setting the severity to important for now. Once Python 3.15 is released
and later added to python3-defaults, this bug will become release
critical.