[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] BUG, PATCH: Don't barf on invalid Unix font files



A small patch to prevent a ValueError when getting a list of fonts on
Unix; this fixes Debian bug #337120.

--- pygame-1.7.1release.orig/lib/sysfont.py
+++ pygame-1.7.1release/lib/sysfont.py
@@ -149,7 +149,9 @@
 #read the fonts from a unix 'fonts.dot' file
 def read_unix_fontsdir(dir, file, fonts):
     file = open(os.path.join(dir, file))
-    numfonts = int(file.readline())
+    try: numfonts = int(file.readline())
+    except ValueError: return # probably not a font file
+
     for line in file.readlines():
         font, descr = (line.split(' ', 1) + ['', ''])[:2]
         if font[-4:].lower() not in [".ttf", ".ttc"]:
-- 
Joe Wreschnig <piman@xxxxxxxxxxxxxx>

Attachment: signature.asc
Description: This is a digitally signed message part