Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.

Bug 2155447

Summary: python-pyside2 fails to build with Python 3.12: error: use of undeclared identifier 'PyUnicode_AS_UNICODE'
Product: [Fedora] Fedora Reporter: Tomáš Hrnčiar <thrnciar>
Component: python-pyside2Assignee: Richard Shaw <hobbes1069>
Status: NEW --- QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 38CC: hobbes1069, laurent.rineau__fedora, mhroncok, orion, thrnciar, tuju
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: 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: 2135404, 2219998    
Attachments:
Description Flags
Support for python 3.12 none

Description Tomáš Hrnčiar 2022-12-21 09:37:50 UTC
python-pyside2 fails to build with Python 3.12.0a3.

/builddir/build/BUILD/pyside-setup-opensource-src-5.15.7/redhat-linux-build/sources/pyside2/PySide2/QtCore/PySide2/QtCore/qtcore_module_wrapper.cpp:2977:27: error: use of undeclared identifier 'PyUnicode_AS_UNICODE'
    Py_UNICODE *unicode = PyUnicode_AS_UNICODE(pyIn);
                          ^
Leagcy Unicode APIs has been removed. See PEP 623 for detail.
        PyUnicode_WCHAR_KIND
        PyUnicode_AS_UNICODE()
        PyUnicode_AsUnicode()
        PyUnicode_AsUnicodeAndSize()
        PyUnicode_AS_DATA()
        PyUnicode_FromUnicode()
        PyUnicode_GET_SIZE()
        PyUnicode_GetSize()
        PyUnicode_GET_DATA_SIZE()

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

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.12/fedora-rawhide-x86_64/05129590-python-pyside2/

For all our attempts to build python-pyside2 with Python 3.12, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.12/package/python-pyside2/

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

Let us know here if you have any questions.

Python 3.12 is planned to be included in Fedora 39. To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.12.
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 Ben Cotton 2023-02-07 15:03:47 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 38 development cycle.
Changing version to 38.

Comment 2 Orion Poplawski 2023-07-15 15:33:46 UTC
Created attachment 1975932 [details]
Support for python 3.12

I tried to address this with the attached patch and update to 5.15.10, but then the build fails with:

In file included from /builddir/build/BUILD/pyside-setup-opensource-src-5.15.10/redhat-linux-build/sources/pyside2/PySide2/QtGui/PySide2/QtGui/qdragmoveevent_wrapper.cpp:63:
/builddir/build/BUILD/pyside-setup-opensource-src-5.15.10/redhat-linux-build/sources/pyside2/PySide2/QtGui/PySide2/QtGui/qdragmoveevent_wrapper.h:55:220: error: no member named 'DragMove' in 'QOpenGLShader'; did you mean simply 'DragMove'?
    QDragMoveEventWrapper(const QPoint & pos, QFlags<Qt::DropAction> actions, const QMimeData * data, QFlags<Qt::MouseButton> buttons, QFlags<Qt::KeyboardModifier> modifiers, QFlags<QOpenGLShader::ShaderTypeBit> type = QOpenGLShader::DragMove);
                                                                                                                                                                                                                           ^~~~~~~~~~~~~~~~~~~~~~~
                                                                                                                                                                                                                           DragMove
/usr/include/qt5/QtCore/qcoreevent.h:107:9: note: 'DragMove' declared here
        DragMove = 61,                          // drag moves in widget
        ^
In file included from /builddir/build/BUILD/pyside-setup-opensource-src-5.15.10/redhat-linux-build/sources/pyside2/PySide2/QtGui/PySide2/QtGui/qdragmoveevent_wrapper.cpp:63:
/builddir/build/BUILD/pyside-setup-opensource-src-5.15.10/redhat-linux-build/sources/pyside2/PySide2/QtGui/PySide2/QtGui/qdragmoveevent_wrapper.h:55:213: error: no viable conversion from 'QEvent::Type' to 'QFlags<QOpenGLShader::ShaderTypeBit>'
    QDragMoveEventWrapper(const QPoint & pos, QFlags<Qt::DropAction> actions, const QMimeData * data, QFlags<Qt::MouseButton> buttons, QFlags<Qt::KeyboardModifier> modifiers, QFlags<QOpenGLShader::ShaderTypeBit> type = QOpenGLShader::DragMove);
                                                                                                                                                                                                                    ^                     ~~~~~~~~
/usr/include/qt5/QtCore/qflags.h:89:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'QEvent::Type' to 'const QFlags<ShaderTypeBit> &' for 1st argument
class QFlags
      ^
/usr/include/qt5/QtCore/qflags.h:89:7: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'QEvent::Type' to 'QFlags<ShaderTypeBit> &&' for 1st argument
/usr/include/qt5/QtCore/qflags.h:121:29: note: candidate constructor not viable: no known conversion from 'QEvent::Type' to 'QOpenGLShader::ShaderTypeBit' for 1st argument
    Q_DECL_CONSTEXPR inline QFlags(Enum flags) noexcept : i(Int(flags)) {}
                            ^
/usr/include/qt5/QtCore/qflags.h:123:80: note: candidate constructor not viable: no known conversion from 'QEvent::Type' to 'Zero' (aka 'int (QFlags<QOpenGLShader::ShaderTypeBit>::Private::*)') for 1st argument
    QT_DEPRECATED_X("Use default constructor instead") Q_DECL_CONSTEXPR inline QFlags(Zero) noexcept : i(0) {}
                                                                               ^
/usr/include/qt5/QtCore/qflags.h:125:29: note: candidate constructor not viable: no known conversion from 'QEvent::Type' to 'QFlag' for 1st argument
    Q_DECL_CONSTEXPR inline QFlags(QFlag flag) noexcept : i(flag) {}
                            ^
/usr/include/qt5/QtCore/qflags.h:127:29: note: candidate constructor not viable: no known conversion from 'QEvent::Type' to 'std::initializer_list<ShaderTypeBit>' for 1st argument
    Q_DECL_CONSTEXPR inline QFlags(std::initializer_list<Enum> flags) noexcept
                            ^
/builddir/build/BUILD/pyside-setup-opensource-src-5.15.10/redhat-linux-build/sources/pyside2/PySide2/QtGui/PySide2/QtGui/qdragmoveevent_wrapper.h:55:213: note: passing argument to parameter 'type' here
    QDragMoveEventWrapper(const QPoint & pos, QFlags<Qt::DropAction> actions, const QMimeData * data, QFlags<Qt::MouseButton> buttons, QFlags<Qt::KeyboardModifier> modifiers, QFlags<QOpenGLShader::ShaderTypeBit> type = QOpenGLShader::DragMove);
                                                                                                                                                                                                                    ^
/builddir/build/BUILD/pyside-setup-opensource-src-5.15.10/redhat-linux-build/sources/pyside2/PySide2/QtGui/PySide2/QtGui/qdragmoveevent_wrapper.cpp:103:240: error: no matching constructor for initialization of 'QDragMoveEvent'
QDragMoveEventWrapper::QDragMoveEventWrapper(const QPoint & pos, QFlags<Qt::DropAction> actions, const QMimeData * data, QFlags<Qt::MouseButton> buttons, QFlags<Qt::KeyboardModifier> modifiers, QFlags<QOpenGLShader::ShaderTypeBit> type) : QDragMoveEvent(pos, actions, data, buttons, modifiers, type)
                                                                                                                                                                                                                                               ^              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/qt5/QtGui/qevent.h:684:5: note: candidate constructor not viable: no known conversion from 'QFlags<QOpenGLShader::ShaderTypeBit>' to 'Type' for 6th argument
    QDragMoveEvent(const QPoint &pos, Qt::DropActions actions, const QMimeData *data,
    ^
/usr/include/qt5/QtGui/qevent.h:681:20: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 6 were provided
class Q_GUI_EXPORT QDragMoveEvent : public QDropEvent
                   ^
/builddir/build/BUILD/pyside-setup-opensource-src-5.15.10/redhat-linux-build/sources/pyside2/PySide2/QtGui/PySide2/QtGui/qdragmoveevent_wrapper.cpp:218:73: error: no member named 'DragMove' in 'QOpenGLShader'
        ::QFlags<QOpenGLShader::ShaderTypeBit> cppArg5 = QOpenGLShader::DragMove;
                                                         ~~~~~~~~~~~~~~~^
4 errors generated.

And koschei reports that pyside2 has been FTBFS for a long time (2023-04-04) https://koschei.fedoraproject.org/package/python-pyside2?last_seen_ts=1680967022&collection=f39

Upstream reports that the 5.15 branch is closed - so perhaps it's time to retire this package?

Comment 3 Richard Shaw 2023-07-18 02:51:07 UTC
To be honest I fixed the inital problem with ChatGPT so I need to evaluate your patch, but the bigger problem:

This was discussed on the devel mailing list, it's needs to be addressed in Qt5, not Pyside2.
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/IJQ3KMKJFIKEVY4WX5WMQFYUGAVB2G2M/#TPQFP6W22XACTGIBLDL3TG6HA322HWPR