classification
Title: imghdr raise TypeError for PNG
Type: behavior Stage: resolved
Components: Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, lorenzogotuned
Priority: normal Keywords:

Created on 2018-09-24 14:21 by lorenzogotuned, last changed 2018-09-24 14:25 by christian.heimes. This issue is now closed.

Messages (2)
msg326237 - (view) Author: (lorenzogotuned) Date: 2018-09-24 14:21
Found on Python 3.6

This line https://github.com/python/cpython/blob/master/Lib/imghdr.py#L45
always raises`TypeError`as `startswith` does not accept bytes.
msg326239 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2018-09-24 14:25
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
History
Date User Action Args
2018-09-24 14:25:24christian.heimessetstatus: open -> closed

type: crash -> behavior

nosy: + christian.heimes
messages: + msg326239
resolution: not a bug
stage: resolved
2018-09-24 14:21:07lorenzogotunedcreate