[issue38672] mimetypes.init() fails if no access to one of known files

R. David Murray report at bugs.python.org
Sun Nov 24 13:34:02 EST 2019


R. David Murray <rdmurray at bitdance.com> added the comment:

I haven't looked at this in detail, but here are my general thoughts: I think it would be reasonable to expect that the module would function even if the file permissions are screwed up, similar to how unix commands that try to read .netrc will (try to) function even if its permissions are wrong.  I would, however, expect the module to emit a warning in that case.  I'm of two minds about the behavior when the caller specifies filenames explicitly.  I could see that going either way, but I lean slightly toward making the behavior consistent.  While the programmer might appreciate the traceback, the user of the program would probably appreciate the "try to keep going" behavior, since the filenames provided will often be in the same class of "standard defaults" as the existing well known files are, just in the context of that particular application.  But like I said, that is just a lean, and I could go the other way on this as well :)

I haven't looked at the isflie issue, but it seems reasonable that if the path exists we should make sure it is a file before reading it...but perhaps readfp will effectively do that?  Write a test and see what happens :)

I don't know whether to call this change a bug fix or a feature, so I guess we'd default to feature unless someone can tilt the balance with an argument :)

----------

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


More information about the Python-bugs-list mailing list