On 64-bit windows, I noticed the value of the QPainter pointer can exceed the maximum unsigned long int value, which caused a python OverflowError. Changing the type to size_t should prevent this.