summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorBrian Curtin <brian@python.org>2012-12-27 20:04:42 (GMT)
committerBrian Curtin <brian@python.org>2012-12-27 20:04:42 (GMT)
commit172e42295fa846bb253f698da10150906f723f52 (patch)
tree0f5295694a80c6e3f70e8000983ecdadc5c5bc9a /Lib/test
parent12706f20825f78afa8305c1cbeb47900a790c21a (diff)
downloadcpython-172e42295fa846bb253f698da10150906f723f52.zip
cpython-172e42295fa846bb253f698da10150906f723f52.tar.gz
cpython-172e42295fa846bb253f698da10150906f723f52.tar.bz2
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.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_winreg.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_winreg.py b/Lib/test/test_winreg.py
index 68c12eb..a164d2f 100644
--- a/Lib/test/test_winreg.py
+++ b/Lib/test/test_winreg.py
@@ -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):