[issue34787] imghdr raise TypeError for PNG

Christian Heimes report at bugs.python.org
Mon Sep 24 10:25:24 EDT 2018


Christian Heimes <lists at cheimes.de> added the comment:

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

----------
nosy: +christian.heimes
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed
type: crash -> behavior

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34787>
_______________________________________


More information about the Python-bugs-list mailing list