diff options
author | RUANG (James Roy) <longjinyii@outlook.com> | 2025-02-14 17:26:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-14 17:26:26 (GMT) |
commit | 303043f5062c1e7ffb7907abde61dbf13c98f8e9 (patch) | |
tree | 603d91aa78959ab18838171990806b598dc8a356 | |
parent | 3402e133ef26736296c07992266a82b181a5d532 (diff) | |
download | cpython-303043f5062c1e7ffb7907abde61dbf13c98f8e9.zip cpython-303043f5062c1e7ffb7907abde61dbf13c98f8e9.tar.gz cpython-303043f5062c1e7ffb7907abde61dbf13c98f8e9.tar.bz2 |
gh-128703: Fix mimetypes.guess_type for empty Content-Type in registry (GH-128854)
-rw-r--r-- | Lib/mimetypes.py | 2 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2025-01-15-12-04-30.gh-issue-128703.6WPf38.rst | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py index 7532383..3e1c3cf 100644 --- a/Lib/mimetypes.py +++ b/Lib/mimetypes.py @@ -90,6 +90,8 @@ class MimeTypes: 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 0000000..1e6af90 --- /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. |