Bug 2245281

Summary: python-distlib fails to build with Python 3.13: ScriptTestCase.test_script_run fails (unexpected empty stdout of subprocess, possibly related to missing cgi module)
Product: [Fedora] Fedora Reporter: Karolina Surma <ksurma>
Component: python-distlibAssignee: Miro Hrončok <mhroncok>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: cstratak, ksurma, logans, mhroncok, python-packagers-sig, torsava
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-11-29 13:12:49 UTC 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: 2244836    

Description Karolina Surma 2023-10-20 13:52:01 UTC
python-distlib fails to build with Python 3.13.0a1.

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

The test fails:

________________________ ScriptTestCase.test_script_run ________________________

self = <test_scripts.ScriptTestCase testMethod=test_script_run>

    def test_script_run(self):
        files = self.maker.make('test = cgi:print_directory')
        self.assertEqual(len(files), 2)
        p = subprocess.Popen([sys.executable, files[0]],
                             stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdout, stderr = p.communicate()
>       self.assertIn(b'<H3>Current Working Directory:</H3>', stdout)
E       AssertionError: b'<H3>Current Working Directory:</H3>' not found in b''

tests/test_scripts.py:334: AssertionError
=========================== short test summary info ============================
FAILED tests/test_scripts.py::ScriptTestCase::test_script_run - AssertionErro...
===== 1 failed, 200 passed, 34 skipped, 3 deselected, 3 warnings in 10.58s =====


For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.13/fedora-rawhide-x86_64/06550785-python-distlib/

For all our attempts to build python-distlib with Python 3.13, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.13/package/python-distlib/

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.13:
https://copr.fedorainfracloud.org/coprs/g/python/python3.13/

Let us know here if you have any questions.

Python 3.13 is planned to be included in Fedora 41. To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.13.
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 Miro Hrončok 2023-10-20 13:59:12 UTC
For the record, the original test failures are:

________________________ ScriptTestCase.test_script_run ________________________

self = <test_scripts.ScriptTestCase testMethod=test_script_run>

    def test_script_run(self):
        files = self.maker.make('test = cgi:print_directory')
        self.assertEqual(len(files), 2)
        p = subprocess.Popen([sys.executable, files[0]],
                             stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdout, stderr = p.communicate()
>       self.assertIn(b'<H3>Current Working Directory:</H3>', stdout)
E       AssertionError: b'<H3>Current Working Directory:</H3>' not found in b''

tests/test_scripts.py:334: AssertionError
__________________________________ test_suite __________________________________

    def test_suite():
        #README = os.path.join(os.path.dirname(__file__), 'README.txt')
        #suite = [doctest.DocFileSuite(README), unittest.makeSuite(VersionTestCase)]
>       suite = [unittest.makeSuite(VersionTestCase),
                 unittest.makeSuite(CompatibilityTestCase),
                 unittest.makeSuite(LegacyVersionTestCase),
                 unittest.makeSuite(SemanticVersionTestCase)]

tests/test_version.py:648: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

name = 'makeSuite'

    def __getattr__(name):
        if name == 'IsolatedAsyncioTestCase':
            global IsolatedAsyncioTestCase
            from .async_case import IsolatedAsyncioTestCase
            return IsolatedAsyncioTestCase
>       raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
E       AttributeError: module 'unittest' has no attribute 'makeSuite'

/usr/lib64/python3.13/unittest/__init__.py:80: AttributeError



However, test_suite is not a test. Upstream does not use pytest, they use unittest and they have a function called test_suite which is used to "prepare" the test suite. It uses functions removed from unittest in Python 3.13. pytest collects this function as a test (due to the name of the function), executes it and it normally succeeds (there are no asserts). However now it fails.

While this probably needs to be addressed upstream, a simple workaround was to deselect the non-test.


-------------


The actual failure here is test_script_run. I belive that the called subprocess fails (the call does not check that) and the error is in stderr (the test does not display that). Possibly related to the missing cgi module.

Comment 2 Miro Hrončok 2023-10-23 11:18:27 UTC
I believe the test is using the cgi module only as a convenient way to test running a script created by ScriptMaker.make().

As such, skipping it for now in copr.

Comment 3 Miro Hrončok 2023-10-23 11:26:16 UTC
Reported upstream https://github.com/pypa/distlib/issues/208

Comment 4 Miro Hrončok 2023-10-24 12:01:00 UTC
And fixed upstream https://github.com/pypa/distlib/commit/e27569b02d9718c19ece71ce6d5124b967277399

Comment 5 Miro Hrončok 2023-11-22 12:22:29 UTC
A downstream backport: https://src.fedoraproject.org/rpms/python-distlib/pull-request/17