[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[pygame] Weird crashes with 1.5.x




Hi,

We recently started using Pygame 1.5, at least Pygame itself calls it so:

Python 2.1.3 (#1, Jul 29 2002, 22:34:51)
[GCC 2.95.4 20011002 (Debian prerelease)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> import pygame
>>> pygame.version.ver
'1.5'

This version introduced at least in Civil a heap of random and totally
weird crashes. It seems to be something with the 'rect' code that gets
abused somewhere, or just plain crashes. We can crash the game in at least
two different locations with the same error, while running the exact same
codebase. We get a stacktrace like this:

  [rets of stacktrace nuked]

  File "./state/action.py", line 83, in __init__
    self.ordersview_visible = scenario.playfield.getLayer ( "orders_view").isVisible ()
  File "./playfield/playfield.py", line 314, in getLayer
    if layer.getName () == name:
AttributeError: 'None' object has no attribute 'rect'


If we look what we have on that line where it crashes we have this little
method:

    def getLayer (self, name):
        """Returns the layer with 'name' from the list of layers. If no 
           layer can be found then None is returned.""" 
        # loop over all layers
        for layer in self.layers:
            # is this the correct layer?
            if layer.getName () == name:  # HERE IT DIES
                return layer

        # no layer found
        return None


Looks simple enough. No rect handling here, nothing related to Pygame at
all. Ok, if we look at the getName() method we get:

    def getName (self):
        "Returns the name of the layer."
        return self.name

Returns a string. Nothing to do with rects here either. The classes that
the "layer" variable refer to does contain surfaces and other
Pygame-stuff, so somehow I'm lead to believe that something may be screwed
up internally with the layers. To make it all really weird I can print the
layer on the line before it dies, and that sometimes makes it work. The
"layer" variable itself is not None, it's perfectly ok.

This code has worked for ages with 1.4 without any changes. I don't
remember where the other crashes are, as I don't get them, but Marcus
does, and it's not the same location.

I'm baffled. Any clue? I haven't tested 1.5.x, where x>0, as they aren't
available as Debian packages. Did plain 1.5 contain some weird stuff?

Regards,
	Chakie

-- 
                 "Students?" barked the Archchancellor.
    "Yes, Master. You know? They're the thinner ones with the pale faces?
  Because we're a university? They come with the whole thing, like rats --"
                                         -- Terry Pratchett, Moving Pictures

____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org