pombreda / pgreloaded

Automatically exported from code.google.com/p/pgreloaded
Other
0 stars 0 forks source link

Integer overflow when moving pygame.Rect object #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
import pygame2
import time

rect = pygame2.Rect(50,50,10,10)
while True:
    print("Left:" + str(rect.left) + ", Right:" + str(rect.right))
    rect.centerx -= 10
    time.sleep(0.2)

is a simple test case. As soon as rect.right becomes negative, Python raises an 
"OverflowError: Python int too large to convert to C long"
If you substitute left and right to top and bottom, the same will happen when 
bottom becomes negative. 

rect = pygame2.Rect(50,50,10,10)
while True:
    print("Left:" + str(rect.left) + ", Right:" + str(rect.right))
    rect.move_ip((-10,0))
    time.sleep(0.2)

This example uses move_ip(). Instead of raising an OverflowError, this 
operation code makes rect.right wrap around silently.

Version: pgreloaded alpha 5, Windows 7, Python 3.1.2

If you need more information, I'm often hanging in #pygame, with nick MigoMipo.

Original issue reported on code.google.com by john.eri...@gmail.com on 21 Jul 2010 at 8:11

GoogleCodeExporter commented 9 years ago
This was caused by a signedness/unsignedness optimization issues.
Fixed in rev. 97b18a01ff2e. Thanks!

Original comment by marcusvonappen@googlemail.com on 2 Aug 2010 at 9:29