[issue35026] Winreg's documentation lacks mentioning required permission at some points
New submission from George Fischhof <george@fischhof.hu>: Winreg's documentation lacks mentioning required permission at some points Hi there, on page https://docs.python.org/3/library/winreg.html it is not mentioned in the description of the following functions: winreg.DeleteKey winreg.DeleteKeyEx winreg.DeleteValue that they require KEY_SET_VALUE when the registry key is opened. It is mentioned for example at: winreg.SetValue with the following text: The key identified by the key parameter must have been opened with KEY_SET_VALUE access. BR, George ---------- assignee: docs@python components: Documentation messages: 328034 nosy: docs@python, georgefischhof priority: normal severity: normal status: open title: Winreg's documentation lacks mentioning required permission at some points type: enhancement versions: Python 3.7 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue35026> _______________________________________
Karthikeyan Singaravelan <tir.karthi@gmail.com> added the comment: Thanks for the report. I am adding windows component since it's a windows specific doc issue. RegDeleteValueW
A handle to an open registry key. The key must have been opened with the KEY_SET_VALUE access right. For more information, see Registry Key Security and Access Rights.
https://docs.microsoft.com/en-us/windows/desktop/api/winreg/nf-winreg-regdel... RegDeleteKeyExA https://docs.microsoft.com/en-us/windows/desktop/api/winreg/nf-winreg-regdel... ---------- components: +Windows nosy: +paul.moore, steve.dower, tim.golden, xtreak, zach.ware _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue35026> _______________________________________
Change by Zackery Spytz <zspytz@gmail.com>: ---------- keywords: +patch nosy: +ZackerySpytz nosy_count: 7.0 -> 8.0 pull_requests: +23330 stage: -> patch review pull_request: https://github.com/python/cpython/pull/24547 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue35026> _______________________________________
Eryk Sun <eryksun@gmail.com> added the comment: winreg.DeleteKey[Ex] does not require any particular access on the `key` handle. This handle is used only as the native NT API RootDirectory [1] when opening `subkey` with DELETE access via NtOpenKeyEx [2]. The extra access with winreg.DeleteKeyEx [3] is just to allow explicitly using the 32-bit or 64-bit registry view (i.e. KEY_WOW64_32KEY or KEY_WOW64_64KEY) when traversing the registry. I think this should be clarified in the docs. For example, if you have the predefined handle HKEY_LOCAL_MACHINE as the `key` handle, then deleting r"Software\Spam" will default to traversing the process 32- or 64-bit view of the "Software" key, but you can override the default view. (Note that if you start from a handle for the "Software" key, then setting an explicit view in the access mode doesn't matter since "Software" isn't traversed to reach "Spam" in this case.) winreg.DeleteKeyEx uses KEY_WOW64_64KEY as the default `access` mode. I think this is a mistake. It should default to 0, and thus implicitly traverse the process view from the path of the `key` handle. A 32-bit process should not default to traversing the 64-bit registry view. --- [1] https://docs.microsoft.com/en-us/windows/win32/api/ntdef/ns-ntdef-_object_at... [2] https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-zwo... [3] https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regdelet... ---------- nosy: +eryksun _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue35026> _______________________________________
Change by Eryk Sun <eryksun@gmail.com>: ---------- versions: +Python 3.10, Python 3.8, Python 3.9 -Python 3.7 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue35026> _______________________________________
participants (4)
-
Eryk Sun
-
George Fischhof
-
Karthikeyan Singaravelan
-
Zackery Spytz