python / cpython

The Python programming language
https://www.python.org
Other
62.28k stars 29.92k forks source link

Ensurepip fails ungracefully when mimetype is missing from Windows registry #100256

Open BlipRanger opened 1 year ago

BlipRanger commented 1 year ago

Bug report

A "WinError 5 Access is denied" error occurs when ensurepip (for python 3.10 and above) is run and there are missing/inaccessible mimetypes in the Windows registry. Because ensurepip is used in the Python installer, it also fails silently there, causing pip to never be installed without alerting the user to the issue. The line in which the error occurs is here: https://github.com/python/cpython/blob/024ac542d738f56b36bdeb3517a10e93da5acab9/Lib/mimetypes.py#L250 Bypassing that line and instead using self._read_windows_registry(add_type) (which is the fallback function I believe) fixes the problem. I believe that _mimetypes_read_windows_registry(add_type) needs to be able to fail more gracefully when it can't find a particular mimetype in the registry. I found someone else describing exactly the issue here.

Your environment

Linked PRs

huanghe2015 commented 1 year ago

Same thing happened with me ,Patrick and Stackoverflow.

LucasEsposito commented 1 month ago

Opened a PR to address this issue