Skip to content

Testing Python 3.12 #7727

Closed
Closed

Description

@The-Compiler

While we had Python 3.12 in the CI during its Alpha phase (with zero issues), now in the Beta phase it looks like things start breaking in upstream projects. Removing it from CI for now, until upstream issues are fixed. Here is what I ran into:

pytest

Shows ast deprecation warnings:

Hidden by:

diff --git i/pytest.ini w/pytest.ini
index 46a22c5c8..899118186 100644
--- i/pytest.ini
+++ w/pytest.ini
@@ -63,4 +63,7 @@ filterwarnings =
     default:Test process .* failed to terminate!:UserWarning
     # https://github.com/certifi/python-certifi/issues/170
     ignore:path is deprecated\. Use files\(\) instead\. Refer to https.//importlib-resources\.readthedocs\.io/en/latest/using\.html#migrating-from-legacy for migration advice\.:DeprecationWarning:certifi.core
+    # Python 3.12: https://github.com/pytest-dev/pytest/issues/10977
+    ignore:ast\.(Str|NameConstant|Num) is deprecated and will be removed in Python 3\.14; use ast\.Constant instead:DeprecationWarning
+    ignore:Attribute s is deprecated and will be removed in Python 3\.14; use value instead:DeprecationWarning
 faulthandler_timeout = 90

hypothesis

Triggers syntax error:

I don't really see a way around this, guess we'll need to wait for either Hypothesis or (more likely based on the comment) CPython comes up with a fix for this.

Activity

  1. added
    component: infrastructureIssues related to development scripts, CI, servers, etc.
    priority: 1 - middleIssues which should be done at some point, but aren't that important.
    on May 31, 2023
  2. added a commit that references this issue on May 31, 2023
  3. Zac-HD commented on May 31, 2023

    @Zac-HD

    Happily the lambda source error was a bug in the standard library, and has already been fixed in cpython main.

  4. The-Compiler commented on May 31, 2023

    @The-Compiler
    MemberAuthor

    Thanks for the update, @Zac-HD! Looks like beta 2 is scheduled for June 6th, so looks like we can probably reactivate the CI job in a week or so!

  5. The-Compiler commented on Jun 7, 2023

    @The-Compiler
    MemberAuthor

    Beta 2 is now released - waiting for GitHub Actions to update, and then we can finally give this another try!

  6. The-Compiler commented on Jun 8, 2023

    @The-Compiler
    MemberAuthor

    With this patch:

    commit 0b0401f8bb23fa57bac13e14b522c9755cba05f7
    Author: Florian Bruhin <me@the-compiler.org>
    Date:   Thu Jun 8 17:38:12 2023 +0200
    
        py312: Tell tox/virtualenv to upgrade pip
        
        Otherwise we run into a Python 3.12 incompatibility with pkg_resources:
        https://github.com/pypa/pip/issues/11501
        
        Also needs PIP_REQUIRE_VIRTUALENV=0 because otherwise pip seems to
        falsely assume it's installing things system-wide, weirdly.
        
        Should probably be removed once there is a newer virtualenv, which
        vendors a newer pip, which vendors a newer pkg_resources...
        
        See #7727
    
    diff --git a/tox.ini b/tox.ini
    index 3c1759eb7..606446f70 100644
    --- a/tox.ini
    +++ b/tox.ini
    @@ -16,6 +16,8 @@ setenv =
         pyqt{62,63,64,65}: PYTEST_QT_API=pyqt6
         pyqt{62,63,64,65}: QUTE_QT_WRAPPER=PyQt6
         cov: PYTEST_ADDOPTS=--cov --cov-report xml --cov-report=html --cov-report=
    +    py312: VIRTUALENV_PIP=23.1.2
    +    py312: PIP_REQUIRE_VIRTUALENV=0
     passenv =
         PYTHON
         DISPLAY
    

    I got things to run locally - however, now PyQt seems to segault:

    #0  0x00007ffff792ad50 in _PyDict_Next () at /usr/lib/libpython3.12.so.1.0
    #1  0x00007ffff5e36499 in trawl_hierarchy(_typeobject*, qpycore_metaobject*, QMetaObjectBuilder&, QList<EnumFlag>&, QList<_qpycore_pyqtSignal const*>&, QMap<unsigned int, std::pair<_object*, _object*> >&) ()
        at /home/florian/proj/qutebrowser/git/.tox/py312-pyqt65/lib/python3.12/site-packages/PyQt6/QtCore.abi3.so
    #2  0x00007ffff5e36cc7 in trawl_hierarchy(_typeobject*, qpycore_metaobject*, QMetaObjectBuilder&, QList<EnumFlag>&, QList<_qpycore_pyqtSignal const*>&, QMap<unsigned int, std::pair<_object*, _object*> >&) ()
        at /home/florian/proj/qutebrowser/git/.tox/py312-pyqt65/lib/python3.12/site-packages/PyQt6/QtCore.abi3.so
    #3  0x00007ffff5e36cc7 in trawl_hierarchy(_typeobject*, qpycore_metaobject*, QMetaObjectBuilder&, QList<EnumFlag>&, QList<_qpycore_pyqtSignal const*>&, QMap<unsigned int, std::pair<_object*, _object*> >&) ()
        at /home/florian/proj/qutebrowser/git/.tox/py312-pyqt65/lib/python3.12/site-packages/PyQt6/QtCore.abi3.so
    #4  0x00007ffff5e357ba in qpycore_get_dynamic_metaobject(_sipWrapperType*) [clone .part.0] () at /home/florian/proj/qutebrowser/git/.tox/py312-pyqt65/lib/python3.12/site-packages/PyQt6/QtCore.abi3.so
    #5  0x00007ffff5e363d8 in qpycore_get_qmetaobject(_sipWrapperType*, _sipTypeDef const*) () at /home/florian/proj/qutebrowser/git/.tox/py312-pyqt65/lib/python3.12/site-packages/PyQt6/QtCore.abi3.so
    #6  0x00007ffff5e2a4e5 in qpycore_qobject_finalisation(_object*, QObject*, _object*, _object**) () at /home/florian/proj/qutebrowser/git/.tox/py312-pyqt65/lib/python3.12/site-packages/PyQt6/QtCore.abi3.so
    #7  0x00007ffff62b5bbc in sipSimpleWrapper_init (self=0x7fffd83551d0, args=(None,), kwds=0x0) at sip_core.c:8950
    ...
  7. The-Compiler commented on Jun 8, 2023

    @The-Compiler
    MemberAuthor

    I got it down to this, based on the statusbar.command.Command class:

    import sys
    from PyQt6.QtWidgets import QWidget, QApplication
    
    class Mixin:
        pass
    
    class Command(Mixin, QWidget):
        pass
    
    app = QApplication(sys.argv)
    cmd = Command()
    cmd.show()
    app.exec()

    Bisected in Python to gh-94673: More Per-Interpreter Fields for Builtin Static Types (gh-10… · python/cpython@de64e75.

    Better stacktrace with a debug Python build:

    _PyDict_Next (op=0x0, ppos=0x7fffffffbd50, pkey=0x7fffffffbd58, pvalue=0x7fffffffbd60, phash=phash@entry=0x0) at Objects/dictobject.c:2114
    2114	   if (!PyDict_Check(op))
    (gdb) bt
    #0  _PyDict_Next (op=0x0, ppos=0x7fffffffbd50, pkey=0x7fffffffbd58, pvalue=0x7fffffffbd60, phash=phash@entry=0x0) at Objects/dictobject.c:2114
    #1  0x000055555572a37e in PyDict_Next (op=<optimized out>, ppos=<optimized out>, pkey=<optimized out>, pvalue=<optimized out>) at Objects/dictobject.c:2189
    #2  0x00007ffff2436499 in trawl_hierarchy(_typeobject*, qpycore_metaobject*, QMetaObjectBuilder&, QList<EnumFlag>&, QList<_qpycore_pyqtSignal const*>&, QMap<unsigned int, std::pair<_object*, _object*> >&) ()
       from /home/florian/proj/qutebrowser/.venv/lib/python3.12/site-packages/PyQt6/QtCore.abi3.so
    #3  0x00007ffff2436cc7 in trawl_hierarchy(_typeobject*, qpycore_metaobject*, QMetaObjectBuilder&, QList<EnumFlag>&, QList<_qpycore_pyqtSignal const*>&, QMap<unsigned int, std::pair<_object*, _object*> >&) ()
       from /home/florian/proj/qutebrowser/.venv/lib/python3.12/site-packages/PyQt6/QtCore.abi3.so
    #4  0x00007ffff2436cc7 in trawl_hierarchy(_typeobject*, qpycore_metaobject*, QMetaObjectBuilder&, QList<EnumFlag>&, QList<_qpycore_pyqtSignal const*>&, QMap<unsigned int, std::pair<_object*, _object*> >&) ()
       from /home/florian/proj/qutebrowser/.venv/lib/python3.12/site-packages/PyQt6/QtCore.abi3.so
    #5  0x00007ffff24357ba in qpycore_get_dynamic_metaobject(_sipWrapperType*) [clone .part.0] () from /home/florian/proj/qutebrowser/.venv/lib/python3.12/site-packages/PyQt6/QtCore.abi3.so
    #6  0x00007ffff24363d8 in qpycore_get_qmetaobject(_sipWrapperType*, _sipTypeDef const*) () from /home/florian/proj/qutebrowser/.venv/lib/python3.12/site-packages/PyQt6/QtCore.abi3.so
    #7  0x00007ffff242a4e5 in qpycore_qobject_finalisation(_object*, QObject*, _object*, _object**) () from /home/florian/proj/qutebrowser/.venv/lib/python3.12/site-packages/PyQt6/QtCore.abi3.so
    #8  0x00007ffff74efbbc in sipSimpleWrapper_init (self=0x7ffff765ebb0, args=(), kwds=0x0) at sip_core.c:8950
    #9  0x0000555555758f0d in type_call (type=<optimized out>, type@entry=0x555555e53e60, args=args@entry=(), kwds=kwds@entry=0x0) at Objects/typeobject.c:1671

    Reported to PyQt: https://www.riverbankcomputing.com/pipermail/pyqt/2023-June/045325.html

  8. The-Compiler commented on Jun 9, 2023

    @The-Compiler
    MemberAuthor

    I got rid of the multiple inheritance in 0fe03ae - it was making the code more complex needlessly anyways.

    At least locally, now only two tests are failing with Python 3.12:

    FAILED tests/end2end/test_invocations.py::test_version - AssertionError: assert <ExitStatus.CrashExit: 1> == <ExitStatus.NormalExit: 0>
    FAILED tests/unit/utils/test_standarddir.py::test_no_qapplication - subprocess.CalledProcessError: Command '['/home/florian/proj/qutebrowser/git/.tox/py312-pyqt65/bin/python', '/tmp/pytest-of-florian/pytest-5/test_no_qapplication0/sub.py', '/home/florian/proj/qutebrowser/git/scripts/dev/../..', '/hom...
    

    And indeed a simple qutebrowser --version with Python 3.12 still segfaults on exit... Reported here: Python 3.12: "Python memory allocator called without holding the GIL" on shutdown

  9. The-Compiler commented on Jun 9, 2023

    @The-Compiler
    MemberAuthor

    Tests run fine now - but pytest then segfaults on exit too. So removing from CI again for the time being...

  10. The-Compiler commented on Jul 11, 2023

    @The-Compiler
    MemberAuthor

    python/cpython#106600 made it in just in time - Beta 4 is scheduled for yesterday but apparently wasn't released yet. So hopefully once that's out, we can give this another try on CI.

  11. The-Compiler commented on Jul 12, 2023

    @The-Compiler
    MemberAuthor

    Python 3.12 Beta 4 was released, and the latest PyQt snapshot seems to run our testsuite without any issues!

    Time to re-add it to the CI once Qt 6.5.2 and then PyQt 6.5.2 is out 😅

  12. added a commit that references this issue on Jul 22, 2023
    41e32e8
  13. The-Compiler commented on Jan 23, 2024

    @The-Compiler
    MemberAuthor

    Fixed in 6478496

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: infrastructureIssues related to development scripts, CI, servers, etc.priority: 1 - middleIssues which should be done at some point, but aren't that important.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions