Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hijacked PyQt types are not returned from native Qt APIs #502

Closed
ivany4 opened this issue Nov 11, 2024 · 1 comment · Fixed by #507
Closed

Hijacked PyQt types are not returned from native Qt APIs #502

ivany4 opened this issue Nov 11, 2024 · 1 comment · Fixed by #507
Assignees
Labels
Milestone

Comments

@ivany4
Copy link

ivany4 commented Nov 11, 2024

QtPy 2.4.2 has integrated this PR: #461, which swaps QToolbar and QAction types with custom subclasses. This introduced a new problem that instances returned from Qt no longer pass instance checks.

E.g.:

from qtpy import QtWidgets

app = QtWidgets.QApplication([])
window = QtWidgets.QMainWindow()
new_toolbar = window.addToolBar('Toolbar title')
assert isinstance(new_toolbar, QtWidgets.QToolBar)

This will pass in QtPy 2.4.1 and will fail with QtPy 2.4.2. It now requires to check against true PyQt classes, e.g. assert isinstance(new_toolbar, PyQt5.QtWidgets.QToolBar)

By extension, returned instances will have different behavior from the manually created ones

@ivany4 ivany4 changed the title Hijacked PyQt types fail instance check Hijacked PyQt types are not returned from native Qt APIs Nov 11, 2024
@dalthviz dalthviz added this to the v2.4.3 milestone Dec 12, 2024
@dalthviz
Copy link
Member

Hi @ivany4 thank you for the report and sorry for the late reply! We will revert the wrapper changes to prevent such errors and inconsistencies!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants