This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Claudiu.Popa
Recipients Claudiu.Popa
Date 2013-12-16.12:48:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1387198093.92.0.388328564702.issue19997@psf.upfronthosting.co.za>
In-reply-to
Content
imghdr.what check explicitly for string path, while `open` happily accepts bytes paths, as seen below:

>>> x
b'\xc2\xba'
>>> imghdr.what(x)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tank/libs/cpython/Lib/imghdr.py", line 15, in what
    location = file.tell()
AttributeError: 'bytes' object has no attribute 'tell'
>>> open(x)
<_io.TextIOWrapper name=b'\xc2\xba' mode='r' encoding='UTF-8'>

A reason why this should be supported can be found in this message: http://bugs.python.org/msg191691.
The following patch fixes this. Also, it depends on issue19990 (where test_imghdr.py was added).
History
Date User Action Args
2013-12-16 12:48:13Claudiu.Popasetrecipients: + Claudiu.Popa
2013-12-16 12:48:13Claudiu.Popasetmessageid: <1387198093.92.0.388328564702.issue19997@psf.upfronthosting.co.za>
2013-12-16 12:48:13Claudiu.Popalinkissue19997 messages
2013-12-16 12:48:13Claudiu.Popacreate