In Pyside, why does emitting an integer> 0x7FFFFFFF result in an "OverflowError" after signal processing?

I am trying to use signals / slots with large integers from 0 to 2 ^ 32-1. I found something a little strange - as soon as I emit a border> 7FFFFFFF, I get OverflowError exceptions written after the slot started. I could expect such an overflow if I or QT explicitly used a signed 32-bit integer in another language such as C or C ++ - as we all know, 0x80000000 wraps up to -2 ^ 31 in 2s complement notation. In python, however, its just 2 ^ 32 without packaging. My assumption when writing the code was that it is python and that the int int can grow very large (maybe in an arbitrary way?), And that I clearly do not need to define anything as 32 or 64 bits or signed / unsigned. Everything will work.

The code below shows what I see (Python 2.7.2 (64 bit), Pyside 1.1.0, Windows 7)

from PySide.QtCore import *

@Slot(int)
def say(i):
    print "Say %i" % i

class Communicate(QObject):
    speak = Signal(int)

someone = Communicate()
someone.speak.connect(say)
someone.speak.emit(0x7FFFFFFF) #works fine
someone.speak.emit(0x80000000) #OverflowError after slot "say" runs
say(0x80000000)                #works fine

:

Say 2147483647
Say -2147483648
OverflowError
Say 2147483648
  • Qt, , / integer, 32- , int int?
  • Qt, , int unsigned , QT > 0x7FFFFFFF?
+5
1

PyQt, , . int 4- ( Qt int).

- Python. :

class Communicate(QObject):
    speak = Signal(object)

, , Qt int (, QtGui.QSpinBox.setMaximum), . , Python .

+5

All Articles