Fix UnboundLocalError masking RegistryError in gwinpy Registry. Registry.RemoveKeyValue, SetKeyValue, GetRegKeys and GetRegKeysAndValues assigned handle inside a try block and closed it in finally. When _OpenSubKey failed (for example, the key does not exist), handle was never bound, so handle.Close() raised UnboundLocalError and replaced the original RegistryError. Callers that check RegistryError.errno (for example, treating errno 2 as “already absent”) never saw it. Open the key before the try block, so a failed open propagates its RegistryError unchanged and finally only runs once a handle exists. Add open-failure tests for all four methods, plus success and failure tests for RemoveKeyValue that check the handle is closed. Replace module-global monkeypatching in tests with mock.patch.object. Bump the version to 0.3.10. PiperOrigin-RevId: 1004062859
Fix UnboundLocalError masking RegistryError in gwinpy Registry.
Registry.RemoveKeyValue, SetKeyValue, GetRegKeys and GetRegKeysAndValues assigned handle inside a try block and closed it in finally. When _OpenSubKey failed (for example, the key does not exist), handle was never bound, so handle.Close() raised UnboundLocalError and replaced the original RegistryError. Callers that check RegistryError.errno (for example, treating errno 2 as “already absent”) never saw it.
handle
finally
handle.Close()
Open the key before the try block, so a failed open propagates its RegistryError unchanged and finally only runs once a handle exists.
Add open-failure tests for all four methods, plus success and failure tests for RemoveKeyValue that check the handle is closed. Replace module-global monkeypatching in tests with mock.patch.object. Bump the version to 0.3.10.
PiperOrigin-RevId: 1004062859
The winops repository contains general purpose libraries, small tools and scripts useful for managing Windows computers in an enterprise environment.
We have a public discussion list at google-winops@googlegroups.com
This is not an official Google product.
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802047560号
WinOps
The winops repository contains general purpose libraries, small tools and scripts useful for managing Windows computers in an enterprise environment.
Contact
We have a public discussion list at google-winops@googlegroups.com
Disclaimer
This is not an official Google product.