[PyQt] Integer rollover issue in signals

Rien Korstanje rien.korstanje at gmail.com
Mon Jun 7 10:47:40 BST 2010


I think I have identified an integer roll over issue when using PyQt slots.
When passing a python long through a signal it comes out as an int. Please
see the example below.

Is this a bug? If so, is there a workaround?

Rien Korstanje


Demonstrates an integer overflow in pyqt signals with
Python 2.6.5 and PyQt-Py2.6-gpl-4.7.3-2.

When the button is pressed, a signal is emitted with as argument
maxint + 1. Yet the slot receiving this signal gets minint.

Expected output:

Value that goes in 2147483648
Value that comes out -2147483648

Created on 7 Jun 2010

@author: M.P. Korstanje
import sys

from PyQt4.QtCore import *
from PyQt4.QtGui import *

class Foo(QPushButton):

    barSignal = pyqtSignal((long,),)

    def __init__(self, parent=None):
        super(Foo, self).__init__("Click!", parent)


    def __emitBarSignal(self):
        longValue = long(sys.maxint + 1)
        print "Value that goes in %s" % str(longValue)

    def barSlot(self, value):
        print "Value that comes out %s" % str(value)

if __name__ == '__main__':

    app = QApplication(sys.argv)
    foo = Foo()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100607/02a63922/attachment.html>

More information about the PyQt mailing list