[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Bug in Font.size



Hi,

after long debugging session I've finally found the problem causing "can't resize shared unicode objects" exception in my small pygame program (120 kB of the source code :-)). The problem is on the line 508 in the file font.c:

Py_DECREF(text);

it should be

Py_DECREF(strob);


The sample program demonstrating the bug:

import pygame
from pygame.locals import *

pygame.init()
screen = pygame.display.set_mode((800, 600), SWSURFACE, 32)

font = pygame.font.Font(None, 30)

text = u""

for i in xrange(0, 10):
text = u'%s%d' % (text, i)

textSize = font.size(text) # comment this to remove the bug

srfc = font.render(text, 1, (0xff, 0xff, 0xff), (0x00, 0x00, 0x00))
screen.blit(srfc, (0, 0))
pygame.display.update()

Tested on Python 2.2.3, Pygame 1.5.5D, Window 2000.
I hope it can be fixed soon :-)

Ludek