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

Re: [pygame] pgu broken with pygame 1.8.1release ? - patch for one bug(crash)



I would make the argument that this assertion was broken from the start. Did pygame ever guarantee that it would be a tuple? Would be better to check if its a sequence, maybe something like:

try:
    tuple(x)
except TypeError:
    # Not a sequence
else:
    # A sequence

(the biggest problem with the above is that is will think a string is a sequence in this context)

Kinda makes you wish that PySequence_Check was exposed in python somehow. Ironically googling for "PySequence_Check" brings up such a discussion as the first hit.

-Casey

On Aug 14, 2008, at 5:49 PM, René Dudfield wrote:

ah, bugger.

I don't think we can fix this error in pygame.

As the code was using:
if type(x) == tuple:

Unfortunately we can't make the Color type a tuple type.


This is annoying, because pgu is used by a lot of games.  So the Color
changes in pygame 1.8.1 will break a lot of things.  Well, they'll
need to patch pgu.






On Fri, Aug 15, 2008 at 12:46 AM, claudio canepa <ccanepacc@xxxxxxxxx> wrote:
Knowing that a number of pygame games used pgu, and on top of that pyweek is
near, I take the liberty to re-post at pygame-users.

pgu broken with pygame 1.8.1release ? - patch for one bug(crash)
Nine of the demos crash with the same (except script name) traceback:

Traceback (most recent call last):
 File "F:\cla 2008 08 13\trunk\examples\gui11.py", line 67, in ?
   app.run(main)
 File "..\pgu\gui\app.py", line 207, in run
   self.loop()
 File "..\pgu\gui\app.py", line 163, in loop
   us = self.update(s)
 File "..\pgu\gui\app.py", line 188, in update
   self.paint(screen)
 File "..\pgu\gui\app.py", line 174, in paint
   container.Container.paint(self,screen)
 File "..\pgu\gui\container.py", line 100, in paint
   w.paint(sub)
 File "..\pgu\gui\theme.py", line 288, in func
   r = m(surface.subsurface(s,w._rect_content))
 File "..\pgu\gui\container.py", line 100, in paint
   w.paint(sub)
 File "..\pgu\gui\theme.py", line 288, in func
   r = m(surface.subsurface(s,w._rect_content))
 File "..\pgu\gui\container.py", line 100, in paint
   w.paint(sub)
 File "..\pgu\gui\theme.py", line 288, in func
   r = m(surface.subsurface(s,w._rect_content))
 File "..\pgu\gui\container.py", line 100, in paint
   w.paint(sub)
 File "..\pgu\gui\theme.py", line 286, in func
   w.background.paint(surface.subsurface(s,w._rect_border))
 File "..\pgu\gui\theme.py", line 473, in paint
   self.theme.render(s,v,r)
 File "..\pgu\gui\theme.py", line 404, in render
   ww,hh=box.get_width()/3,box.get_height()/3
AttributeError: 'pygame.Color' object has no attribute 'get_width'

The offending scripts are:
gui6.py
gui11.py
gui13.py
gui15.py
gui16.py
gui17.py

html2.py
html3.py
html5.py

Besides, gui9.py don't crash but misbehaves: with pygame 1.7.1 you can draw
boxes and circles but with pygame 1.8.1release no boxes and circles.

I tried pgu '0.10.6' ( checked out from imitation pickles, rev 38 ), also
pgu-0.10.6.tar.gz from sourceforge and pgu 0.10.3, same results.

The demos run fine with pygame 1.7.1

Extra info:
win xp + sp2, python 2.4.3

Okay, found the problem for the crashes: will manifest in widgets with solid
color background.
Cause: color was a tuple, now it is a pygame.colors.Color instance. See
patch for details.
A patch (against pgu svn imitation pickles r38) is attached.
It is pygame 1.7.1 and 1.8.1 compatible.

The other problem (gui9.py misbehaving with pygame 1.8.1release) remains.

--
claxo

-------------------------