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.

classification
Title: imghdr.what should take one argument
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.5
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: Claudiu.Popa, SilentGhost, iritkatriel, jfinkels
Priority: normal Keywords: patch

Created on 2011-07-07 19:56 by jfinkels, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
imghdr.patch jfinkels, 2011-07-07 19:56 review
Messages (4)
msg139993 - (view) Author: Jeffrey Finkelstein (jfinkels) * Date: 2011-07-07 19:56
Currently imghdr.what() accepts two parameters. The first is a file or filename and the second is a byte stream. If the second is not None, the first is ignored. This is clunky. It would be simpler to accept just one argument, which can be either an open file or a byte stream.

I have attached a patch which implements this one argument approach as private function imghdr_what(). I have left imghdr.what() as a wrapper around this new function for backwards compatibility (in the hopes that it will eventually be replaced).

In addition, there did not seem to be any tests for the imghdr module, so I added a few simple tests.
msg140034 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2011-07-08 16:20
This seems like a change suitable for 3.3
msg220361 - (view) Author: PCManticore (Claudiu.Popa) * (Python triager) Date: 2014-06-12 16:08
imghdr got a test file in 94813eab5a58. Your patch also needs documentation updates. Besides that, +1 from me. Maybe it would be okay to add a deprecation warning for the second argument?
msg415043 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2022-03-13 17:11
imghdr is deprecated as per PEP 594, so there won't be more enhancements to it.
History
Date User Action Args
2022-04-11 14:57:19adminsetgithub: 56725
2022-03-13 17:12:50iritkatrielsetresolution: rejected -> wont fix
2022-03-13 17:11:47iritkatrielsetstatus: open -> closed

nosy: + iritkatriel
messages: + msg415043

resolution: rejected
stage: resolved
2014-06-12 16:08:23Claudiu.Popasetmessages: + msg220361
2014-06-12 16:05:04Claudiu.Popasetnosy: + Claudiu.Popa

versions: + Python 3.5, - Python 3.3
2011-07-08 16:20:20SilentGhostsetnosy: + SilentGhost

messages: + msg140034
versions: + Python 3.3, - Python 3.4
2011-07-07 19:56:45jfinkelscreate