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

64-bit long raises incorrect OverflowError (possibly related to QVariant conversion) #126

Open
codewarrior0 opened this issue Sep 6, 2015 · 0 comments

Comments

@codewarrior0
Copy link

An OverflowError is raised when passing a 64-bit long value through the data method of a QSortFilterProxyModel. This only occurs on Linux. No error occurs and the correct value is returned on Windows. In both cases, 64-bit builds of Python 2.7.8 and PySide 1.2.2 are used.

First, here is the minimal example needed to reproduce this error:

from PySide import QtGui, QtCore
from PySide.QtCore import Qt

class TestModel(QtCore.QAbstractListModel):
    def rowCount(self, parent=None):
        return 1

    def data(self, index, role=Qt.DisplayRole):
        if role == Qt.DisplayRole:
            return (1 << 45)


def main():
    model = TestModel()
    proxyModel = QtGui.QSortFilterProxyModel()
    proxyModel.setSourceModel(model)
    val = proxyModel.data(proxyModel.index(0, 0, QtCore.QModelIndex()))
    assert (1<<45) == val

if __name__ == '__main__':
    main()

And the error that results:

    val = proxyModel.data(proxyModel.index(0, 0, QtCore.QModelIndex()))
OverflowError

This error is surprising, and is not justified by any of the other reasons for raising an OverflowError (e.g. passing a 64-bit value into a Qt function whose argument type is int or short). This is because QAbstractItemModel and subclasses have a QVariant return type for data().

I have not tested this with debug builds of PySide, so this is only my suspicion: The CppWrapper for TestModel will convert the Py_Long returned by the Python data method into a QVariant, and this is where the OverflowError occurs.

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

No branches or pull requests

1 participant