[Image-SIG] Patch for ImageFont.py from PIL 1.0B1

Barry Scott barry@scottb.demon.co.uk
Mon, 22 Mar 1999 22:10:34 -0000


In ImageFont.py the function load_path uses "except:" this catches
too many errors. I suggest this version of the function:

def load_path(filename):
    "Load a font file, searching along the Python path."
    for dir in sys.path:
	 try:
	    return load(os.path.join(dir, filename))
	 except IOError:
	    pass
    raise IOError, "cannot find font file"

I found this out because I upgraded FreeBSD from 2.2.8 to 3.1 and
now get the following error that I'm assuming means I must recompile
Python and PIL for the new ELF image format of FreeBSD 3.X.

  File "./isdn_status.py", line 461, in create_graph_single
    title_face = ImageFont.load_path("BDF/75dpi/timR14.pil")
  File "/usr/local/lib/python1.5/site-packages/PIL/ImageFont.py", line 115,
in load_path
    return load(os.path.join(dir, filename))
  File "/usr/local/lib/python1.5/site-packages/PIL/ImageFont.py", line 106,
in load
    f._load_pilfont(filename)
  File "/usr/local/lib/python1.5/site-packages/PIL/ImageFont.py", line 79,
in _load_pilfont
    self.image.load()
  File "/usr/local/lib/python1.5/site-packages/PIL/ImageFile.py", line 111,
in load
    self.map = Image.core.map(self.filename)
  File "/usr/local/lib/python1.5/site-packages/PIL/Image.py", line 36, in
__getattr__
    raise ImportError, "The _imaging C module is not installed"
ImportError: The _imaging C module is not installed

		Barry