Message375794
@_savage, on the commit @xtreak referred, there's a note that "image/jpg" and some other non-standard mimetypes are only supported if `strict=False`[1]
So, this:
>>> mimetypes.guess_extension("image/jpg")
Gives no return. But this works:
>>> mimetypes.guess_extension("image/jpg", strict=False)
'.jpg'
---------
I guess we could improve the current documentation [2]. It currently specifies correctly the `strict` behavior:
> The optional strict argument is a flag specifying whether the list of known MIME types is limited to
> only the official types registered with IANA. When strict is True (the default), only the IANA types
> are supported; when strict is False, some additional non-standard but commonly used MIME types are
> also recognized.
But I think it would be nice to have a table specifying what are those "non-standard but commonly used MIME types". Personally, I'd have a hard time guessing on a regular day of my life which of 'image/jpeg' and 'image/jpg' is standard or not. We could even add a nice note pointing out that the `common_types` property [3] is a list of those supported non-standard type .
Given the fact that the `strict` flag is used by different methods with the same behavior, maybe we could add a note on the top of the doc explaining the general meaning of that flag.
[1]: https://github.com/python/cpython/commit/2a99fd911ebeecedbb250a05667cd46eca4735b9#diff-fc65388a9cdf41980b2c31de5de67758R547
[2]: https://docs.python.org/3.10/library/mimetypes.html#mimetypes.guess_type
[3]: https://docs.python.org/3.10/library/mimetypes.html#mimetypes.common_types |
|
Date |
User |
Action |
Args |
2020-08-22 11:22:21 | fbidu | set | recipients:
+ fbidu, _savage, corona10, xtreak |
2020-08-22 11:22:21 | fbidu | set | messageid: <1598095341.77.0.496295429301.issue37943@roundup.psfhosted.org> |
2020-08-22 11:22:21 | fbidu | link | issue37943 messages |
2020-08-22 11:22:21 | fbidu | create | |
|