[issue41749] Allow omission of imghdr.what file arg if bytes are given

Terry J. Reedy report at bugs.python.org
Fri Sep 11 21:18:37 EDT 2020


Terry J. Reedy <tjreedy at udel.edu> added the comment:

The opening message confused me by using 'need' as 'currently required to call' rather than 'required to compute (test) and necessarily needed to call'; but after reading the code, I believe I understand and modified title to match.  More simply, one could call what(h=b'...') after the change instead of what(None, b'...').  This is the change in the tests (but the old form must still be tested also).

I don't see how the change would affect correct legacy use.  (The TypeError to ValueError change is wrong, and I don't understand the other exception change.)  However, what('') should get the same error as currently (see additional change in review).

However, what is very problemmatic is requiring 1 of 2 different arguments.  For range, the first parameter is really 'start_or_stop', an int either way, with the interpretation depending on the presence of a second.  This is a nuisance for understanding, but a convenience in usage.  But I think requiring an argument (usually) passed positionally or an argument that now has to be passed by keyword, with an arbitrary letter name, is worse and less justified.  So my current view is that this change should be rejected.

----------
nosy: +terry.reedy
title: Little improve on imghdr library -> Allow omission of imghdr.what file arg if bytes are given
type: behavior -> enhancement

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


More information about the Python-bugs-list mailing list