Issue 34787: imghdr raise TypeError for PNG (original) (raw)
startswith supports bytes just fine:
$ python3 Python 3.6.6 (default, Jul 19 2018, 14:25:17) [GCC 8.1.1 20180712 (Red Hat 8.1.1-5)] on linux Type "help", "copyright", "credits" or "license" for more information.
with open('test.png', 'rb') as f: ... header = f.read(1024) ... header.startswith(b'\211PNG\r\n\032\n') True