-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
bpo-43984: Update winreg.SetValueEx to make sure the value set is not -1 #25775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
1f2d523
b00fc84
7841714
1123340
7bbb3f2
c5755dd
ad67138
ec0ea5a
62541b8
27b8130
41a70e0
26b1af4
3fe16ef
dbe8651
1d5df04
666742c
afdee9f
06da229
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,7 +114,6 @@ def _write_test_data(self, root_key, subkeystr="sub_key", | |
"does not close the actual key!") | ||
except OSError: | ||
pass | ||
|
||
def _read_test_data(self, root_key, subkeystr="sub_key", OpenKey=OpenKey): | ||
# Check we can get default value for this key. | ||
val = QueryValue(root_key, test_key_name) | ||
|
@@ -340,7 +339,23 @@ def test_setvalueex_value_range(self): | |
SetValueEx(ck, "test_name", None, REG_DWORD, 0x80000000) | ||
finally: | ||
DeleteKey(HKEY_CURRENT_USER, test_key_name) | ||
|
||
|
||
def test_setvalueex_negative_one_check(self): | ||
AlexWaygood marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# Test for Issue #43984, check -1 was not set by SetValueEx. | ||
# Py2Reg, which gets called by SetValueEx, wasn't checking return | ||
# value by PyLong_AsUnsignedLong, thus setting -1 as value in the registry. | ||
# The implementation now checks PyLong_AsUnsignedLong return value to assure | ||
# the value set was not -1. | ||
try: | ||
with CreateKey(HKEY_CURRENT_USER, test_key_name) as ck: | ||
with self.assertRaises(OverflowError): | ||
SetValueEx(ck, "test_name", None, REG_DWORD, -1) | ||
with self.assertRaises(FileNotFoundError): | ||
with QueryValueEx(ck, "test_name") as subkey: | ||
pass | ||
shreyanavigyan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
finally: | ||
DeleteKey(HKEY_CURRENT_USER, test_key_name) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's something wrong with this test I added. My antivirus is identifying this piece of code as virus. Any thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If any maintainers figure out the problem please add the required commit. Who cannot add commits please suggest the patch, I'll commit it.
AlexWaygood marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
AlexWaygood marked this conversation as resolved.
Show resolved
Hide resolved
|
||
def test_queryvalueex_return_value(self): | ||
# Test for Issue #16759, return unsigned int from QueryValueEx. | ||
# Reg2Py, which gets called by QueryValueEx, was returning a value | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
:meth:`winreg.SetValueEx` now leaves the target register untouched in case of conversion errors. | ||
Previously, ``-1`` would be written in case of such errors. | ||
|
||
shreyanavigyan marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.