Bug 2423881

Summary: python-kaptan fails to build with Python 3.15: AttributeError: 'SourceFileLoader' object has no attribute 'load_module'. Did you mean: 'exec_module'? in test_py_file_handler and test_py_file_away_handler
Product: [Fedora] Fedora Reporter: Karolina Surma <ksurma>
Component: python-kaptanAssignee: Davide Cavalca <davide>
Status: NEW --- QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: davide, epel-packagers-sig, fti-bugs, ksurma, mhroncok
Target Milestone: ---Flags: fti-bugs: needinfo? (davide)
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2412434, 2433833, 2433836    

Description Karolina Surma 2025-12-19 14:49:36 UTC
python-kaptan fails to build with Python 3.15.0a3.

__________________________ test_py_file_away_handler ___________________________

tmpdir = local('/tmp/pytest-of-mockbuild/pytest-0/test_py_file_away_handler0')
testconfig = {'debug': False}

    def test_py_file_away_handler(tmpdir, testconfig):
        py_file = tmpdir.join('config2.py')
        py_file.write("""DATABASE = 'mysql://root:123456@localhost/girlz'
    DEBUG = False
    PAGINATION = {
    'per_page': 10,
    'limit': 20,
    }
    """)
        config = kaptan.Kaptan()
>       config.import_config(str(py_file))

tests/test_kaptan.py:273: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../BUILDROOT/usr/lib/python3.15/site-packages/kaptan/__init__.py:91: in import_config
    self.configuration_data = self.handler.load(data)
                              ^^^^^^^^^^^^^^^^^^^^^^^
../BUILDROOT/usr/lib/python3.15/site-packages/kaptan/handlers/pyfile_handler.py:55: in load
    module = import_pyfile(file_)
             ^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

pathname = '/tmp/pytest-of-mockbuild/pytest-0/test_py_file_away_handler0/config2.py'
mod_name = ''

    def import_pyfile(pathname, mod_name=''):
        """Import the contents of filepath as a Python module.
    
        Parameters
        ----------
        pathname: str
            Path to the .py file to be imported as a module
    
        mod_name: str
            Name of the module when imported
    
        Returns
        -------
        mod
            The imported module
    
        Raises
        ------
        IOError
            If file is not found
        """
        if not os.path.isfile(pathname):
            raise IOError('File {0} not found.'.format(pathname))
    
        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'?

FAILED tests/test_kaptan.py::test_py_file_handler - AttributeError: 'SourceFi...
FAILED tests/test_kaptan.py::test_py_file_away_handler - AttributeError: 'Sou...

https://docs.python.org/3.15/whatsnew/3.15.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.15/fedora-rawhide-x86_64/09935355-python-kaptan/

For all our attempts to build python-kaptan with Python 3.15, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.15/package/python-kaptan/

Testing and mass rebuild of packages is happening in copr.
You can follow these instructions to test locally in mock if your package builds with Python 3.15:
https://copr.fedorainfracloud.org/coprs/g/python/python3.15/

Let us know here if you have any questions.

Python 3.15 is planned to be included in Fedora 45.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.15.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires),
so if this package is required a lot, it's important for us to get it fixed soon.

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Karolina Surma 2026-06-06 18:23:25 UTC
*** Bug 2485883 has been marked as a duplicate of this bug. ***

Comment 2 Fedora Fails To Install 2026-06-14 07:11:53 UTC
Hello,

Please note that this comment was generated automatically by https://forge.fedoraproject.org/releng/tooling/src/branch/main/release-process/bug-filing/follow-policy/follow_policy.py
If you feel that this output has mistakes, please open an issue at https://forge.fedoraproject.org/releng/tickets/issues

This package fails to install and maintainers are advised to take one of the following actions:

 - Fix this bug and close this bugzilla once the update makes it to the repository.
   (The same script that posted this comment will eventually close this bugzilla
   when the fixed package reaches the repository, so you don't have to worry about it.)

or

 - Move this bug to ASSIGNED if you plan on fixing this, but simply haven't done so yet.

or

 - Orphan the package if you no longer plan to maintain it.


If you do not take one of these actions, the process at https://docs.fedoraproject.org/en-US/fesco/Fails_to_build_from_source_Fails_to_install/#_package_removal_for_long_standing_ftbfs_and_fti_bugs will continue.
This package may be orphaned in 7+ weeks.
This is the first reminder (step 3) from the policy.

Don't hesitate to ask for help on https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/ if you are unsure how to fix this bug.