Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6922a1d

Browse files
committed
gh-100256: Skip inaccessible registry keys in the mimetype WinAPI implementation
1 parent e059aa6 commit 6922a1d

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2104,5 +2104,6 @@ Jelle Zijlstra
21042104
Gennadiy Zlobin
21052105
Doug Zongker
21062106
Peter Åstrand
2107+
Lucas Esposito
21072108

21082109
(Entries should be added in rough alphabetical order by last names)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Skip inaccessible registry keys in the WinAPI mimetype implementation (similar to the
2+
behavior of the WinReg implementation)

Modules/_winapi.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2806,6 +2806,11 @@ _winapi__mimetypes_read_windows_registry_impl(PyObject *module,
28062806
if (err == ERROR_FILE_NOT_FOUND) {
28072807
err = ERROR_SUCCESS;
28082808
continue;
2809+
} else if (err == ERROR_ACCESS_DENIED) {
2810+
/* Skip keys we can't access, as we do on the fallback WinReg implementation */
2811+
PyErr_SetFromWindowsErr(err);
2812+
err = ERROR_SUCCESS;
2813+
continue;
28092814
} else if (err != ERROR_SUCCESS) {
28102815
continue;
28112816
}

0 commit comments

Comments
 (0)