|
From: Gregory L. <gre...@ff...> - 2004-06-25 16:42:20
|
Another hackish debugging technique is to insert a lot of print
statements in matplotlib.matlab to find out where the crash is
occurring, ie, on which import line.
Good idea, this helped me to isolate the problem:
it is in font_manager, in the createFontDict function...
Here is my output:
Import matplotlib
Matplotlib.use("PS")
Import matplotlib.font_manager
....lot of add_fname...
Add_fname
Done add_fname
Done add_decorated_fname
Assertion failed:ob_refcnt == 0 in cxx_extension.cxx, line 1031
With my "printified" createFontDict
def createFontDict(fontfiles, fontext='ttf'):
"""A function to create a dictionary of font file paths. The
default is to create a dictionary for TrueType fonts. An AFM font
dictionary can optionally be created.
"""
print "in createFontDict"
fontdict = {}
# Add fonts from list of known font files.
seen = {}
for fname in fontfiles:
if seen.has_key(fname): continue
else: seen[fname] = 1
if fontext == 'ttf':
try:
font = ft2font.FT2Font(str(fname))
except RuntimeError:
print >> sys.stderr, "Could not open font file", fname
continue
prop = ttfFontProperty(font)
elif fontext == 'afm':
try:
#print 'parsing', fname
font = afm.AFM(file(fname))
except RuntimeError:
print >> sys.stderr, "Could not open font file", fname
continue
print "calling afmFontProperty"
prop = afmFontProperty(font)
print " done"
print "add_fname"
add_filename(fontdict, prop, fname)
print "done add_fname"
# !!!! Default font algorithm needs improvement
if prop.name.lower() in ['bitstream vera serif', 'times']:
prop.name = 'serif'
add_filename(fontdict, prop, fname)
elif prop.name.lower() in ['bitstream vera sans', 'helvetica']:
prop.name = 'sans-serif'
add_filename(fontdict, prop, fname)
elif prop.name.lower() in ['zapf chancery', 'itc zapf
chancery']:
prop.name = 'cursive'
add_filename(fontdict, prop, fname)
elif prop.name.lower() in ['western', 'itc avant garde gothic']:
prop.name = 'fantasy'
add_filename(fontdict, prop, fname)
elif prop.name.lower() in ['bitstream vera sans mono',
'courier']:
prop.name = 'monospace'
add_filename(fontdict, prop, fname)
print "done add_decorated_fname"
print "now return fontdict"
return fontdict
So it seems to crash at the end of the for loop, probably on destruction
of a
Temporary object...strange, isn't it? Well, I hope it can help indentify
the problem, at least it isolated it somewhat...If you have any idea of
a test I can do for going further in the bug hunting (well, if it really
is a bug), I will be happy to do it :-)
Best regards,
Greg.
|