[issue37943] mimetypes.guess_extension() doesn’t get JPG right

Jens Troeger report at bugs.python.org
Sat Aug 24 19:06:17 EDT 2019


New submission from Jens Troeger <jens.troeger at gmail.com>:

I think this one’s quite easy to reproduce:

  Python 3.7.4 (default, Jul 11 2019, 01:08:00) 
  [Clang 10.0.1 (clang-1001.0.46.4)] on darwin
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import mimetypes
  >>> mimetypes.guess_extension("image/jpg")  # Expected ".jpg"
  >>> mimetypes.guess_extension("image/jpeg")  # Expected ".jpg"
  '.jpe'

According to MDN

  https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types

only "image/jpeg" is a valid MIME type; however, I’ve seen quite a bit of "image/jpg" out in the wild and I think that ought to be accounted for too.

Before I look into submitting a PR I wanted to confirm that this is an issue that ought to be fixed. I think it is.

----------
components: Library (Lib)
messages: 350408
nosy: _savage
priority: normal
severity: normal
status: open
title: mimetypes.guess_extension() doesn’t get JPG right
type: behavior
versions: Python 3.7

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


More information about the Python-bugs-list mailing list