]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix pnm test for short files and add X bitmap as recognized type
authorGuido van Rossum <guido@python.org>
Wed, 3 Jun 1992 16:48:44 +0000 (16:48 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 3 Jun 1992 16:48:44 +0000 (16:48 +0000)
Lib/imghdr.py

index b653cded2fd0744fdee064b84c4ce8a705a6140b..981340fff075f80f847934d4542772b1f3efb723 100644 (file)
@@ -37,7 +37,8 @@ tests.append(test_gif)
 
 def test_pnm(h, f):
        # PBM, PGM, PPM (portable {bit,gray,pix}map; together portable anymap)
-       if h[0] == 'P' and h[1] in '123456' and h[2] in ' \t\n\r':
+       if len(h) >= 3 and \
+               h[0] == 'P' and h[1] in '123456' and h[2] in ' \t\n\r':
                return 'pnm'
 
 tests.append(test_pnm)
@@ -56,6 +57,14 @@ def test_rast(h, f):
 
 tests.append(test_rast)
 
+def test_xbm(h, f):
+       # X bitmap (X10 or X11)
+       s = '#define '
+       if h[:len(s)] == s:
+               return 'xbm'
+
+tests.append(test_xbm)
+
 
 #--------------------#
 # Small test program #