https://github.com/python/cpython/commit/d78e113d1be83f9edd267989693a051493ad6baa
commit: d78e113d1be83f9edd267989693a051493ad6baa
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: zooba <[email protected]>
date: 2025-02-17T15:36:49Z
summary:

gh-128703: Fix mimetypes.guess_type for empty Content-Type in registry 
(GH-128854)

(cherry picked from commit 303043f5062c1e7ffb7907abde61dbf13c98f8e9)

Co-authored-by: RUANG (James Roy) <[email protected]>

files:
A Misc/NEWS.d/next/Library/2025-01-15-12-04-30.gh-issue-128703.6WPf38.rst
M Lib/mimetypes.py

diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py
index 8604000ed77a19..2af7c4b7b80822 100644
--- a/Lib/mimetypes.py
+++ b/Lib/mimetypes.py
@@ -95,6 +95,8 @@ def add_type(self, type, ext, strict=True):
         list of standard types, else to the list of non-standard
         types.
         """
+        if not type:
+            return
         self.types_map[strict][ext] = type
         exts = self.types_map_inv[strict].setdefault(type, [])
         if ext not in exts:
diff --git 
a/Misc/NEWS.d/next/Library/2025-01-15-12-04-30.gh-issue-128703.6WPf38.rst 
b/Misc/NEWS.d/next/Library/2025-01-15-12-04-30.gh-issue-128703.6WPf38.rst
new file mode 100644
index 00000000000000..1e6af90bc04b63
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2025-01-15-12-04-30.gh-issue-128703.6WPf38.rst
@@ -0,0 +1,2 @@
+Fix :func:`mimetypes.guess_type` to use default mapping for empty
+``Content-Type`` in registry.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to