diff options
author | Guido van Rossum <guido@python.org> | 1992-06-03 16:48:44 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1992-06-03 16:48:44 (GMT) |
commit | 05b55e76f07805af719f53d9c832871774a855aa (patch) | |
tree | af884a4be2f75801a94bc3c793570e5304327492 | |
parent | d482e8ad4a11c7cbe9374f449da036ad21a5ee55 (diff) | |
download | cpython-05b55e76f07805af719f53d9c832871774a855aa.zip cpython-05b55e76f07805af719f53d9c832871774a855aa.tar.gz cpython-05b55e76f07805af719f53d9c832871774a855aa.tar.bz2 |
Fix pnm test for short files and add X bitmap as recognized type
-rw-r--r-- | Lib/imghdr.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/imghdr.py b/Lib/imghdr.py index b653cde..981340f 100644 --- a/Lib/imghdr.py +++ b/Lib/imghdr.py @@ -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 # |