mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Fix #16759. Convert DWORD registry values using PyLong_FromUnsignedLong.
When converting REG_DWORD registry values into Python ints, the conversion needs to be made from an *unsigned* long to match the DWORD type.
This commit is contained in:
parent
12706f2082
commit
172e42295f
3 changed files with 23 additions and 2 deletions
|
@ -335,6 +335,23 @@ class LocalWinregTests(BaseWinregTests):
|
|||
finally:
|
||||
DeleteKey(HKEY_CURRENT_USER, test_key_name)
|
||||
|
||||
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
|
||||
# generated by PyLong_FromLong. The implmentation now uses
|
||||
# PyLong_FromUnsignedLong to match DWORD's size.
|
||||
try:
|
||||
with CreateKey(HKEY_CURRENT_USER, test_key_name) as ck:
|
||||
self.assertNotEqual(ck.handle, 0)
|
||||
test_val = 0x80000000
|
||||
SetValueEx(ck, "test_name", None, REG_DWORD, test_val)
|
||||
ret_val, ret_type = QueryValueEx(ck, "test_name")
|
||||
self.assertEqual(ret_type, REG_DWORD)
|
||||
self.assertEqual(ret_val, test_val)
|
||||
finally:
|
||||
DeleteKey(HKEY_CURRENT_USER, test_key_name)
|
||||
|
||||
|
||||
|
||||
@unittest.skipUnless(REMOTE_NAME, "Skipping remote registry tests")
|
||||
class RemoteWinregTests(BaseWinregTests):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue