The mimetypes module in Python 3.13 is missing mappings for modern Microsoft Office OpenXML formats, causing guess_extension() and guess_all_extensions() to return None/[] for common MIME types like application/vnd.openxmlformats-officedocument.wordprocessingml.document.
Environment
Python Version: 3.13.3
Platform: Docker containers (minimal base images)
Module: mimetypes
Problem Description
When using mimetypes.guess_extension() with modern Office MIME types, the function returns None instead of the expected file extensions:
importmimetypes# These should return extensions but don't:print(mimetypes.guess_extension('application/vnd.openxmlformats-officedocument.wordprocessingml.document')) # Should be '.docx'print(mimetypes.guess_extension('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')) # Should be '.xlsx' print(mimetypes.guess_extension('application/vnd.openxmlformats-officedocument.presentationml.presentation')) # Should be '.pptx'# All return: None
Missing MIME Type Mappings
The following critical modern Office formats are missing:
Expected: .docx extension returned Actual: None returned
Suggested Fix
Add the missing OpenXML MIME type mappings to the mimetypes module's built-in database:
# Should be added to mimetypes default mappings:'.docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'.xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'.pptx': 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
These formats have been standard since Microsoft Office 2007 (17+ years) and are widely used in web applications.
Activity
StanFromIreland commented on Aug 19, 2025
These were added in 1cf9b6d in Python 3.14, I don’t think we can backport since it is a new feature.
CC @hugovk
hugovk commented on Aug 19, 2025
Correct, generally we've not been backporting these. On the bright side, it's not long until 3.14!
Thanks anyway for the report.