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

Re: [pygame] Font-Related Segfault



This is a guess, but maybe pygame assumes the object passed to Font is a real file object? If so there's a bug there that it doesn't type- check and throw an exception, if not it seems like there's a bug there that it blows up rather than throwing an exception, but that may be something outside of the pygame code anyway.

Could you work around this by writing the data to a file (maybe using a TemporaryFile object) and use that instead of StringIO?

-Casey

On Nov 23, 2009, at 1:38 PM, Bryce Schroeder wrote:

(My apologies if this is a double-post. I didn't get a copy of the
message or see it in the archive, so I'm trying again.)

I have a pygame program that worked in the past on both Linux and
Windows, but now results in a segfault, at least on Linux.  (I can't
test it on Windows.)
The segfault occurs in this code:

class Font(Resource):
 ....
  def pygame_font(self,size):
      return pygame.font.Font(StringIO.StringIO(self.parts['font']),
size) # Segfaults here


self.parts['font'] is a string containing a truetype font loaded from
a file. I have checked that the string contains the file like it is
supposed too. Any suggestions?