summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorBrian Curtin <brian@python.org>2012-12-27 20:37:06 (GMT)
committerBrian Curtin <brian@python.org>2012-12-27 20:37:06 (GMT)
commit33e05e7905c00f601e4d1fea9ec0df0b3b9cb39c (patch)
tree929086c8cd2953a05aee4d5e7826ad301dc8631e /Lib/test
parenta0b7e9c74c36cadf2546612788795986dca64484 (diff)
downloadcpython-33e05e7905c00f601e4d1fea9ec0df0b3b9cb39c.zip
cpython-33e05e7905c00f601e4d1fea9ec0df0b3b9cb39c.tar.gz
cpython-33e05e7905c00f601e4d1fea9ec0df0b3b9cb39c.tar.bz2
Fix #16759. Convert DWORD registry values using unsigned long.
When converting REG_DWORD registry values into Python, the conversion needs to be made from an *unsigned* long (k instead of i) 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 c4ae737..2799e19 100644
--- a/Lib/test/test_winreg.py
+++ b/Lib/test/test_winreg.py
@@ -326,6 +326,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):