[PyQt] PyQt and integer overflows

Florian Bruhin me at the-compiler.org
Wed May 14 14:50:35 BST 2014


Hi,

I think the exception PyQt prints when passing an integer value which
is too big for the underlying C function is rather confusing:

    >>> from PyQt5.QtCore import QSize
    >>> QSize(2**64, 0)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: arguments did not match any overloaded call:
      [...]
      QSize(int, int): argument 1 has unexpected type 'int'

I think if possible it should detect the *type* is in fact correct,
and raise an OverflowError or so instead.

Also, how can I detect what the largest value is I can safely pass in?
It seems to be different on my Windows and Linux system (both 64 bit
though). On Windows, 2**32 / 2 - 1 is the largest value, on Linux
2**64 instead. I tried using struct to get the size of an int, but
that's the same on both platforms:

    >>> struct.calcsize('@i') * 8
    >>> 32

Florian

-- 
() ascii ribbon campaign - stop html mail    www.asciiribbon.org
/\ www.the-compiler.org  | I love long mails http://email.is-not-s.ms/
Giving money and power to governments is like giving whiskey and car keys to 
teenage boys. -- P.J. O'Rourke 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20140514/0ee0069d/attachment.sig>


More information about the PyQt mailing list