GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — mimetypes module does not recognize jp2 type · Issue #85957 · python/cpython

mimetypes module does not recognize jp2 type #85957

New issue
Copy link
New issue
Copy link
Closed
#126966
Closed
mimetypes module does not recognize jp2 type#85957
#126966
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

Description

naro
mannequin
opened on Sep 15, 2020
Issue body actions
BPO 41791
Nosy @naro, @iritkatriel

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2020-09-15.04:31:47.953>
labels = ['type-feature', '3.11']
title = 'mimetypes module does not recognize jp2 type'
updated_at = <Date 2022-01-19.00:38:51.433>
user = 'https://github.com/naro'

bugs.python.org fields:

activity = <Date 2022-01-19.00:38:51.433>
actor = 'adelfino'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = []
creation = <Date 2020-09-15.04:31:47.953>
creator = 'naro'
dependencies = []
files = []
hgrepos = []
issue_num = 41791
keywords = []
message_count = 5.0
messages = ['376927', '377074', '377086', '377113', '410860']
nosy_count = 2.0
nosy_names = ['naro', 'iritkatriel']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue41791'
versions = ['Python 3.11']

Linked PRs

  • gh-85957: Add missing MIME types for images with RFCs #126966

Activity

Next
  1. naro commented on Sep 15, 2020

    @naro
    naromannequin
    on Sep 15, 2020
    MannequinAuthor
    More actions

    Even if jp2 is in the official list of types https://www.iana.org/assignments/media-types/media-types.xhtml it's not recognized by the MimeTypes.guess_type:

    >>> from mimetypes import MimeTypes
    >>> MimeTypes().guess_type('test.jp2')
    (None, None)

    The same example works in Python 3.7 and returns 'image/jp2'

  2. naro
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    3.8 (EOL)end of lifeend of life
    on Sep 15, 2020
  3. andresdelfino commented on Sep 17, 2020

    @andresdelfino
    andresdelfino
    on Sep 17, 2020
    Contributor
    More actions

    Hi, Radim!

    I've tested with 3.7.8 and got (None, None). I'm curious on how you got that 'image/jp2' output.

    It seems jp2 was never supported by looking into the git history of Lib/mimetypes.py.

    Would you like to open a PR to support it? :)

  4. naro commented on Sep 18, 2020

    @naro
    naromannequin
    on Sep 18, 2020
    MannequinAuthor
    More actions

    Hi Andrés,

    tried again and the difference is between 3.7.4 and 3.7.5
    The jp2 mimetype is read from /etc/apache2/mime.types (see knownfiles in mimetypes.py) so the mime type does not have to be in the mimetypes.py hardcoded, but in version 3.7.5 it stopped working.

    I think it's because of using _types_map_default instead of types_map in some places.

    Since jp2 is an official mime type it should be added to the list but I also think we should try to identify the issue with _types_map_default.

    Seems to be related to https://bugs.python.org/issue4963

    I will have look if I can find out what was changed and why.

    Cheers,
    Radim

  5. andresdelfino commented on Sep 18, 2020

    @andresdelfino
    andresdelfino
    on Sep 18, 2020
    Contributor
    More actions

    Nice debugging!

  6. iritkatriel commented on Jan 18, 2022

    @iritkatriel
    iritkatriel
    on Jan 18, 2022
    Member
    More actions

    It is found by the module-level guess_type but not by the MimeType class's guess_type:

    >>> from mimetypes import MimeTypes
    >>> MimeTypes().guess_type('test.jp2')
    (None, None)
    >>> import mimetypes
    >>> mimetypes.guess_type('test.jp2')
    ('image/jp2', None)
    >>> 

    That difference is the subject of bpo-38656.

    What remains to decide here is whether jp2 should be added to the builtin list of mimetypes.

  7. iritkatriel
    added
    3.11only security fixesonly security fixes
    type-featureA feature request or enhancementA feature request or enhancement
    and removed
    3.8 (EOL)end of lifeend of life
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Jan 18, 2022
  8. 2 remaining items

  9. ezio-melotti
    transferred this issue fromon Apr 10, 2022
  10. iritkatriel
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Nov 23, 2023
  11. josselinbuils
    added 6 commits that reference this issue on Jan 8, 2024

    fix(lab-2558): manage mimetypes module issue on Windows

    d999ed6

    fix(lab-2558): manage mimetypes module issue on Windows

    25eb238

    fix(lab-2558): manage mimetypes module issue on Windows

    9b1d95b

    fix(lab-2558): manage mimetypes module issue on Windows

    e6e7581

    fix(lab-2558): manage mimetypes module issue on Windows

    90912c7

    fix(lab-2558): manage mimetypes module issue on Windows

    0754b47
  12. hugovk commented on Nov 18, 2024

    @hugovk
    hugovk
    on Nov 18, 2024
    Member
    More actions

    Please see PR #126966.

  13. hugovk
    added
    3.14bugs and security fixesbugs and security fixes
    and removed
    3.11only security fixesonly security fixes
    3.14bugs and security fixesbugs and security fixes
    on Nov 18, 2024
  14. hugovk
    added a commit that references this issue on Nov 18, 2024

    gh-85957: Add missing MIME types for images with RFCs (#126966)

    933f21c
  15. hugovk
    closed this as completedin #126966on Nov 18, 2024
  16. ebonnal
    added a commit that references this issue on Jan 12, 2025

    pythongh-85957: Add missing MIME types for images with RFCs (python#1…

    2d53a34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.