[Pythonmac-SIG] pyui font troubles

David Hill davidh at mac.com
Wed Jul 13 00:22:53 CEST 2005


Hi,

I'm relatively new to Python and I'm trying to work through some  
examples in Sean Riley's "Game Programming with Python" book.  
Unfortunately, I'm having some trouble with most of the examples that  
use his pyui library.

It looks like the examples fail when trying to create a font object  
for the arial font. I took a look in the pyui code that creates the  
font (using pygame) and it has this suspicious line:

>  faceFile = os.environ['WINDIR'] + "/Fonts/" + fontRegistery[faceFile]

where fontRegistery[faceFile] == "arial.ttf"

That didn't fill me with a great deal of confidence (since it  
produces a KeyError exception on WINDIR), so I tried a quick hack:

>             if os.environ.has_key( 'WINDIR' ):
>                 faceFile = os.environ['WINDIR'] + "/Fonts/" +  
> fontRegistery[faceFile]
>             else:
>                 faceFile = "/Library/Fonts/Arial"

That gets me the bus error shown below. Clearly, the font format on  
Mac OS X isn't what pygame is expecting.

Has anybody else had any luck getting the code from this book to work?

The error in the console looks like this:

> davidh% /usr/local/bin/pythonw terrainView.py
> Creating font: arial
> {'impact': 'impact.ttf', 'arial': 'arial.ttf', 'courier':  
> 'cour.ttf', 'courier new': 'cour.ttf', 'times': 'times.ttf', 'comic  
> sans ms': 'comic.ttf', 'times new roman': 'times.ttf'} arial
> Fatal Python error: (pygame parachute) Bus Error
> Abort

The stack crawl from the crash report looks like this:

> Exception:  EXC_BAD_ACCESS (0x0001)
> Codes:      KERN_PROTECTION_FAILURE (0x0002) at 0x00000000
>
> Thread 0 Crashed:
> 0   font.so                       0x007bb464 initfont + 4972
> 1   org.python.python             0x10052e38 type_call + 284  
> (typeobject.c:435)
> 2   org.python.python             0x1000c348 PyObject_Call + 48  
> (abstract.c:1752)
> 3   org.python.python             0x1007c9e4 do_call + 136 (ceval.c: 
> 3755)
> 4   org.python.python             0x1007c6dc call_function + 1068  
> (ceval.c:3572)
> 5   org.python.python             0x1007a140 PyEval_EvalFrame +  
> 8888 (ceval.c:2163)
> 6   org.python.python             0x1007b284 PyEval_EvalCodeEx +  
> 2152 (ceval.c:2730)
> 7   org.python.python             0x10026274 function_call + 344  
> (funcobject.c:548)
> 8   org.python.python             0x1000c348 PyObject_Call + 48  
> (abstract.c:1752)
> 9   org.python.python             0x10015a88 instancemethod_call +  
> 796 (classobject.c:2432)
> 10  org.python.python             0x1000c348 PyObject_Call + 48  
> (abstract.c:1752)
> 11  org.python.python             0x1007c26c  
> PyEval_CallObjectWithKeywords + 256 (ceval.c:3420)
> 12  org.python.python             0x1000eddc PyInstance_New + 320  
> (classobject.c:576)
> 13  org.python.python             0x1000c348 PyObject_Call + 48  
> (abstract.c:1752)
> 14  org.python.python             0x1007c9e4 do_call + 136 (ceval.c: 
> 3755)
> 15  org.python.python             0x1007c6dc call_function + 1068  
> (ceval.c:3572)
> 16  org.python.python             0x1007a140 PyEval_EvalFrame +  
> 8888 (ceval.c:2163)
> 17  org.python.python             0x1007c83c fast_function + 212  
> (ceval.c:3631)
> 18  org.python.python             0x1007c6c4 call_function + 1044  
> (ceval.c:3568)
> 19  org.python.python             0x1007a140 PyEval_EvalFrame +  
> 8888 (ceval.c:2163)
> 20  org.python.python             0x1007b284 PyEval_EvalCodeEx +  
> 2152 (ceval.c:2730)
> 21  org.python.python             0x10026274 function_call + 344  
> (funcobject.c:548)
> 22  org.python.python             0x1000c348 PyObject_Call + 48  
> (abstract.c:1752)
> 23  org.python.python             0x10015a88 instancemethod_call +  
> 796 (classobject.c:2432)
> 24  org.python.python             0x1000c348 PyObject_Call + 48  
> (abstract.c:1752)
> 25  org.python.python             0x1007c9e4 do_call + 136 (ceval.c: 
> 3755)
> 26  org.python.python             0x1007c6dc call_function + 1068  
> (ceval.c:3572)
> 27  org.python.python             0x1007a140 PyEval_EvalFrame +  
> 8888 (ceval.c:2163)
> 28  org.python.python             0x1007b284 PyEval_EvalCodeEx +  
> 2152 (ceval.c:2730)
> 29  org.python.python             0x10026274 function_call + 344  
> (funcobject.c:548)
> 30  org.python.python             0x1000c348 PyObject_Call + 48  
> (abstract.c:1752)
> 31  org.python.python             0x10015a88 instancemethod_call +  
> 796 (classobject.c:2432)
> 32  org.python.python             0x1000c348 PyObject_Call + 48  
> (abstract.c:1752)
> 33  org.python.python             0x1007c26c  
> PyEval_CallObjectWithKeywords + 256 (ceval.c:3420)
> 34  org.python.python             0x1000eddc PyInstance_New + 320  
> (classobject.c:576)
> 35  org.python.python             0x1000c348 PyObject_Call + 48  
> (abstract.c:1752)
> 36  org.python.python             0x1007c9e4 do_call + 136 (ceval.c: 
> 3755)
> 37  org.python.python             0x1007c6dc call_function + 1068  
> (ceval.c:3572)
> 38  org.python.python             0x1007a140 PyEval_EvalFrame +  
> 8888 (ceval.c:2163)
> 39  org.python.python             0x1007b284 PyEval_EvalCodeEx +  
> 2152 (ceval.c:2730)
> 40  org.python.python             0x1007c8cc fast_function + 356  
> (ceval.c:3644)
> 41  org.python.python             0x1007c6c4 call_function + 1044  
> (ceval.c:3568)
> 42  org.python.python             0x1007a140 PyEval_EvalFrame +  
> 8888 (ceval.c:2163)
> 43  org.python.python             0x1007c83c fast_function + 212  
> (ceval.c:3631)
> 44  org.python.python             0x1007c6c4 call_function + 1044  
> (ceval.c:3568)
> 45  org.python.python             0x1007a140 PyEval_EvalFrame +  
> 8888 (ceval.c:2163)
> 46  org.python.python             0x1007b284 PyEval_EvalCodeEx +  
> 2152 (ceval.c:2730)
> 47  org.python.python             0x1007e678 PyEval_EvalCode + 48  
> (ceval.c:484)
> 48  org.python.python             0x100b2ee0 run_node + 76  
> (pythonrun.c:1265)
> 49  org.python.python             0x100b266c  
> PyRun_SimpleFileExFlags + 592 (pythonrun.c:863)
> 50  org.python.python             0x100bf640 Py_Main + 2596 (main.c: 
> 484)
> 51  org.python.python             0x000018d0 0x1000 + 2256
> 52  dyld                          0x8fe01048 _dyld_start + 60



Does anybody have any ideas or suggestions? Is pyui just not Mac (or  
Linux, evidently) friendly? Could I have screwed up my installation  
of Python 2.4 somehow?


Thanks,

Dave


More information about the Pythonmac-SIG mailing list