diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py index 753238354f6d36..3e1c3cf25d8405 100644 --- a/Lib/mimetypes.py +++ b/Lib/mimetypes.py @@ -90,6 +90,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.