[PyQt] Floats accepted for C++ ints?

Florian Bruhin me at the-compiler.org
Tue Jul 5 18:22:14 BST 2016


I've noticed Python floats are accepted when a C++ int is expected,
and simply truncated:

	>>> from PyQt5.QtCore import QRect
	>>> QRect(0.5, 0.5, 0.5, 0.5)
	PyQt5.QtCore.QRect()
	>>> QRect(1.5, 1.5, 1.5, 1.5)
	PyQt5.QtCore.QRect(1, 1, 1, 1)

Is this intended behaviour? I'd have expected to raise a TypeError
(or, if anything, accept floats where .is_integer() is true)

Florian

-- 
http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
         I love long mails! | http://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20160705/77a862c8/attachment.sig>


More information about the PyQt mailing list