Bug 2488356

Summary: pytest fails to build with Python 3.15: NameError: name '__cached__' is not defined + DeprecationWarning: This process (pid=1147) is multi-threaded, use of forkpty() may lead to deadlocks in the child.
Product: [Fedora] Fedora Reporter: Karolina Surma <ksurma>
Component: pytestAssignee: Thomas Moschny <thomas.moschny>
Status: CLOSED DUPLICATE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: dan, maxwell, mhroncok, mrunge, thomas.moschny
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2026-07-27 16:30:05 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: 2412434, 2433833    

Description Karolina Surma 2026-06-12 14:15:27 UTC
pytest fails to build with Python 3.15.0b2.

_________________ TestRewriteOnImport.test_dont_write_bytecode _________________
[gw0] linux -- Python 3.15.0 /usr/bin/python3
self = <test_assertrewrite.TestRewriteOnImport object at 0x7f22cdc67350>
pytester = <Pytester PosixPath('/tmp/pytest-of-mockbuild/pytest-0/popen-gw0/test_dont_write_bytecode0')>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f22d01fa270>
    def test_dont_write_bytecode(self, pytester: Pytester, monkeypatch) -> None:
        monkeypatch.delenv("PYTHONPYCACHEPREFIX", raising=False)
    
        pytester.makepyfile(
            """
            import os
            def test_no_bytecode():
                assert "__pycache__" in __cached__
                assert not os.path.exists(__cached__)
                assert not os.path.exists(os.path.dirname(__cached__))"""
        )
        monkeypatch.setenv("PYTHONDONTWRITEBYTECODE", "1")
>       assert pytester.runpytest_subprocess().ret == 0
E       AssertionError: assert <ExitCode.TESTS_FAILED: 1> == 0
E        +  where <ExitCode.TESTS_FAILED: 1> = <RunResult ret=1 len(stdout.lines)=19 len(stderr.lines)=0 duration=0.23s>.ret
E        +    where <RunResult ret=1 len(stdout.lines)=19 len(stderr.lines)=0 duration=0.23s> = runpytest_subprocess()
E        +      where runpytest_subprocess = <Pytester PosixPath('/tmp/pytest-of-mockbuild/pytest-0/popen-gw0/test_dont_write_bytecode0')>.runpytest_subprocess
/builddir/build/BUILD/pytest-9.0.3-build/pytest-9.0.3/testing/test_assertrewrite.py:1090: AssertionError
----------------------------- Captured stdout call -----------------------------
running: /usr/bin/python3 -mpytest --basetemp=/tmp/pytest-of-mockbuild/pytest-0/popen-gw0/test_dont_write_bytecode0/runpytest-0
     in: /tmp/pytest-of-mockbuild/pytest-0/popen-gw0/test_dont_write_bytecode0
============================= test session starts ==============================
platform linux -- Python 3.15.0b2, pytest-9.0.3, pluggy-1.6.0
rootdir: /tmp/pytest-of-mockbuild/pytest-0/popen-gw0/test_dont_write_bytecode0
collected 1 item
test_dont_write_bytecode.py F                                            [100%]
=================================== FAILURES ===================================
_______________________________ test_no_bytecode _______________________________
    def test_no_bytecode():
>       assert "__pycache__" in __cached__
                                ^^^^^^^^^^
E       NameError: name '__cached__' is not defined
test_dont_write_bytecode.py:3: NameError
=========================== short test summary info ============================
FAILED test_dont_write_bytecode.py::test_no_bytecode - NameError: name '__cac...
============================== 1 failed in 0.01s ===============================
_____________ TestTerminal.test_report_collect_after_half_a_second _____________
[gw2] linux -- Python 3.15.0 /usr/bin/python3
self = <test_terminal.TestTerminal object at 0x7fc6cd1c2d50>
pytester = <Pytester PosixPath('/tmp/pytest-of-mockbuild/pytest-0/popen-gw2/test_report_collect_after_half_a_second0')>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fc6cd709f60>
    def test_report_collect_after_half_a_second(
        self, pytester: Pytester, monkeypatch: MonkeyPatch
    ) -> None:
        """Test for "collecting" being updated after 0.5s"""
        pytester.makepyfile(
            **{
                "test1.py": """
                import _pytest.terminal
    
                _pytest.terminal.REPORT_COLLECTING_RESOLUTION = 0
    
                def test_1():
                    pass
                    """,
                "test2.py": "def test_2(): pass",
            }
        )
        # Explicitly test colored output.
        monkeypatch.setenv("PY_COLORS", "1")
    
>       child = pytester.spawn_pytest("-v test1.py test2.py")
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/builddir/build/BUILD/pytest-9.0.3-build/pytest-9.0.3/testing/test_terminal.py:206: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/builddir/build/BUILD/pytest-9.0.3-build/BUILDROOT/usr/lib/python3.15/site-packages/_pytest/pytester.py:1531: in spawn_pytest
    return self.spawn(cmd, expect_timeout=expect_timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/builddir/build/BUILD/pytest-9.0.3-build/BUILDROOT/usr/lib/python3.15/site-packages/_pytest/pytester.py:1545: in spawn
    child = pexpect.spawn(cmd, logfile=logfile, timeout=expect_timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/lib/python3.15/site-packages/pexpect/pty_spawn.py:205: in __init__
    self._spawn(command, args, preexec_fn, dimensions)
/usr/lib/python3.15/site-packages/pexpect/pty_spawn.py:303: in _spawn
    self.ptyproc = self._spawnpty(self.args, env=self.env,
/usr/lib/python3.15/site-packages/pexpect/pty_spawn.py:315: in _spawnpty
    return ptyprocess.PtyProcess.spawn(args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/lib/python3.15/site-packages/ptyprocess/ptyprocess.py:230: in spawn
    pid, fd = pty.fork()
              ^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    def fork():
        """fork() -> (pid, master_fd)
        Fork and make the child a session leader with a controlling terminal."""
    
        try:
>           pid, fd = os.forkpty()
                      ^^^^^^^^^^^^
E           DeprecationWarning: This process (pid=1147) is multi-threaded, use of forkpty() may lead to deadlocks in the child.

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

For our attempts to build pytest with Python 3.15, see:
https://koji.fedoraproject.org/koji/search?terms=pytest&type=package&match=exact

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 Miro HronĨok 2026-07-27 16:30:05 UTC

*** This bug has been marked as a duplicate of bug 2458644 ***