Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue 12769 mimetypes windows error #13183

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/12769.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes `[WinError 5] Access is denied` when `mimetypes` fails to read `HKEY_CLASSES_ROOT`.
JoaStuart marked this conversation as resolved.
Show resolved Hide resolved
9 changes: 8 additions & 1 deletion src/pip/_internal/operations/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,14 @@ class File:

def __post_init__(self) -> None:
if self.content_type is None:
self.content_type = mimetypes.guess_type(self.path)[0]
try:
self.content_type = mimetypes.guess_type(self.path)[0]
except OSError:
# Thown when `mimetypes` can't access a key inside
# `HKEY_CLASSES_ROOT` on Windows. We can safely ignore
# this because `pip/_internal/utils/unpacking.py#L309 unpack_file()`
# can handle content_type being None and it is not used anywhere else.
pass
JoaStuart marked this conversation as resolved.
Show resolved Hide resolved


def get_http_url(
Expand Down
Loading