From 8f4892ac529b8f7f32d9707eb713300188247b7b Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Wed, 7 Aug 2024 20:39:51 +0200 Subject: [PATCH] gh-100256: Skip inaccessible registry keys in the WinAPI mimetype implementation (GH-122047) (cherry picked from commit 0bd93755f37e6b8beb597787fce39eb141179965) Co-authored-by: Lucas Esposito --- Misc/ACKS | 1 + .../next/Windows/2024-07-19-21-50-54.gh-issue-100256.GDrKba.rst | 1 + Modules/_winapi.c | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Windows/2024-07-19-21-50-54.gh-issue-100256.GDrKba.rst diff --git a/Misc/ACKS b/Misc/ACKS index 20ea85c4adde..15d4470e2842 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -516,6 +516,7 @@ Michael Ernst Ben Escoto Andy Eskilsson André Espaze +Lucas Esposito Stefan Esser Nicolas Estibals Jonathan Eunice diff --git a/Misc/NEWS.d/next/Windows/2024-07-19-21-50-54.gh-issue-100256.GDrKba.rst b/Misc/NEWS.d/next/Windows/2024-07-19-21-50-54.gh-issue-100256.GDrKba.rst new file mode 100644 index 000000000000..f0156ddd4772 --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2024-07-19-21-50-54.gh-issue-100256.GDrKba.rst @@ -0,0 +1 @@ +:mod:`mimetypes` no longer fails when it encounters an inaccessible registry key. diff --git a/Modules/_winapi.c b/Modules/_winapi.c index edb1181809c5..76f18c71a071 100644 --- a/Modules/_winapi.c +++ b/Modules/_winapi.c @@ -2268,7 +2268,7 @@ _winapi__mimetypes_read_windows_registry_impl(PyObject *module, } err = RegOpenKeyExW(hkcr, ext, 0, KEY_READ, &subkey); - if (err == ERROR_FILE_NOT_FOUND) { + if (err == ERROR_FILE_NOT_FOUND || err == ERROR_ACCESS_DENIED) { err = ERROR_SUCCESS; continue; } else if (err != ERROR_SUCCESS) { -- 2.47.3