Error due to unusual font file

Trying to get a colleague to start using python, he ran into trouble,
getting an error exit whenever he tried to fire up
ipython -pylab

After much searching, he figured it out... it appears that a small patch may be
in order. Here is his note :

···

I found it: I have a font installed in my personal fonts
directory that has non-integral sides for the "bounding box"
of the font.

Fortunately, it seems like once I move my ~/.fonts
directory "off to the side" and then run

ipython -pylab

then some of that configuration info must be cached, since I
am able to move my .fonts file back and still have my ipython
-pylab come up.

The offending line is in the return statement below

#Convert string the a python type
_to_int = int
_to_float = float
_to_str = str

def _to_list_of_ints(s):
    s = s.replace(',', ' ')
    return [_to_int(val) for val in s.split()]

and I think a fix would be along the lines of Alan's remark:

    return [_to_int(_to_float(val)) for val in s.split()]

This is in the file

/glb/apps/sss/epd/2.5.4.2.30201/lib/python2.5/site-packages/ma
tplotlib-0.98.5.2n1-py2.5-linux-x86_64.egg/matplotlib/afm.py

Anyway, it works for me.

--
-----------------------------------------------------------------------

Alan K. Jackson | To see a World in a Grain of Sand |
alan@...895... | And a Heaven in a Wild Flower, |
www.ajackson.org | Hold Infinity in the palm of your hand |
Houston, Texas | And Eternity in an hour. - Blake |

-----------------------------------------------------------------------

Thanks Alan, I committed a fix to svn HEAD which should prevent this
crash, with the following comment:

  # some afm files have floats where we are expecting ints -- there is
  # probably a better way to handle this (support floats, round rather
  # than truncate). But I don't know what the best approach is now and
  # this change to _to_int should at least prevent mpl from crashing on
  # these JDH (2009-11-06)

  def _to_int(x):
      return int(float(x))

If other devs know the best way to handle this, please patch as necessary.

···

On Thu, Nov 5, 2009 at 9:09 PM, Alan Jackson <alan@...895...> wrote:

Trying to get a colleague to start using python, he ran into trouble,
getting an error exit whenever he tried to fire up
ipython -pylab