unable to render text

Issue #144 resolved
Anonymous created an issue

Hi,

I'm not too sure if this is the right place to enter this issue. Just trying my hands on some pygame tutorials and I have the following problem when trying to render text.

File "<stdin>", line 1, in <module> File "/Library/Python/2.7/site-packages/pygame/font.py", line 68, in render s, r = super(Font, self).render(text, color, background) SystemError: error return without exception set

Does anyone knows what's wrong?

Comments (11)

  1. donLorenzo

    The Error message indicates that the CPython C-API is being used wrong. To track down the Problem it would be helpful if you could post a minimal example reproducing the exception or at least a link to the tutorial you were following with a comment where the problem occurs.

  2. Lenard Lindstrom

    The error message given by the original poster can only come from the font.py wrapper for the freetype module. I looked at the latest available Pygame installer for Python 2.7-uploaded on 2012-02-17 as of writing this post-and it uses the SDL_ttf based font extension module, written in C. So my guess is a more recent Pygame version was installed on top of another version. So far I have found no ready solution to get the Pygame windows installer to completely replace an earlier Pygame version. I may look into it again.

  3. Lenard Lindstrom

    Okay, this is an x86_64 problem, an overlooked detail that would have simplified debugging. I have duplicated the problem on an Intel iMac, and possibly fixed it—the freetype module specific unit tests pass. Will commit the patch and close this issue once I verify the fix has not broken something else.

  4. Lenard Lindstrom

    Along with changeset 9cac2ec83346, this fixes issue #144

    Changeset 9cac2ec83346 addressed the first bug uncovered by issued #144. This changeset addresses the other problem, with exporting of the Pygame C api.

    This changeset makes the PyGAME_C_API array a C global for each extension module, with the main declaration in the C file that imports a Pygame api, by including pygame.h, and extern in any other C source files which include _pygame.h instead.

    Explanation of the originally reported bug:

    The _freetype extension module is defined over several C source files. The Python level interface is defined in _freetype.c, which imports other Pygame extension modules for their C apis. The other freetype source files are defined in the src/freetype subdirectory. They also access the Pygame C api. Unfortunately, the Pygame C api pointer array PyGAME_C_API was declared as static, giving each C file its own copy of the array. Only the array local to _freetype.c was initialized; the other instances had undefined pointers. In the _PGFT_Render_NewSurface of file ft_render.c, SDL_CreateRGBSurface returned an SDL exception, because the surface width and height values were too large (due to the bug fixed in changeset 9cac2ec83346). A NULL pointer in the PyGAME_C_API entry for PyExc_SDLError meant the PyErr_SetString call failed to set a Python exception. So _PGFT_Render_NewSurface, and subsequently the freetype.Font.render method, returned a NULL object without an exception. Python raised a SystemError as a result.

    → <<cset e5f2ccbf7965>>

  5. Log in to comment