On, Fri Jun 13, 2008, Lenard Lindstrom wrote: > I appreciate the color extension module is still under construction for > 1.8.1 but this bug is unusual and could easily be missed. This is for > Python 2.5.2 on Windows. When running the shadow effects array example > in the Pygame cookbook, http://www.pygame.org/wiki/ShadowEffects, I get > this exception: [long type overflow exception] Luckily this is no error in the Color class, but instead an error in handling long conversions. The Color class just revealed this error. You can produce that failure with simply passing PyInt_AsLong() returns -1 and sets an OverflowError for values, which exceed LONG_MAX. PyLong_AsLong() does the same for LONG_MAX. On 32-bit systems a white color with alpha as opaque is represented as (unsigned) 0xFFFFFFFF (4294967295) LONG_MAX however will usually have 0x7FFFFFFF (2147483647) And whooops, an overflow happens. It won't be escalated nor reset however and silently lie around on the internal error stack. So instead of a simple PyInt_AsLong() check, we have to check for PyInt_AsLong(), PyLong_AsLong() (as PyNumber_Int() returns either a PyInt _or_ PyLong) and then convert to an unsigned long instead of a signed long where necessary. I'm now looking through the code portions, which check for integer and long values to eliminate this error. Regards Marcus
Attachment:
pgpBNtaYORTmx.pgp
Description: PGP signature