summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_winreg.py
diff options
context:
space:
mode:
authorBrian Curtin <brian@python.org>2012-12-27 16:12:45 (GMT)
committerBrian Curtin <brian@python.org>2012-12-27 16:12:45 (GMT)
commit12706f20825f78afa8305c1cbeb47900a790c21a (patch)
tree5dc796bba028f94b3072eb279602abdf54dc47b0 /Lib/test/test_winreg.py
parente26568f81244e3fb62ab07fd0a3405a99ee87895 (diff)
downloadcpython-12706f20825f78afa8305c1cbeb47900a790c21a.zip
cpython-12706f20825f78afa8305c1cbeb47900a790c21a.tar.gz
cpython-12706f20825f78afa8305c1cbeb47900a790c21a.tar.bz2
Fix #14420. Use PyLong_AsUnsignedLong to support the full range of DWORD.
This fixes an OverflowError seen in winreg.SetValueEx when passed winreg.REG_DWORD values that should be supported by the underlying API.
Diffstat (limited to 'Lib/test/test_winreg.py')
-rw-r--r--Lib/test/test_winreg.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_winreg.py b/Lib/test/test_winreg.py
index c7b50dd..68c12eb 100644
--- a/Lib/test/test_winreg.py
+++ b/Lib/test/test_winreg.py
@@ -323,6 +323,18 @@ class LocalWinregTests(BaseWinregTests):
finally:
DeleteKey(HKEY_CURRENT_USER, test_key_name)
+ def test_setvalueex_value_range(self):
+ # Test for Issue #14420, accept proper ranges for SetValueEx.
+ # Py2Reg, which gets called by SetValueEx, was using PyLong_AsLong,
+ # thus raising OverflowError. The implementation now uses
+ # PyLong_AsUnsignedLong to match DWORD's size.
+ try:
+ with CreateKey(HKEY_CURRENT_USER, test_key_name) as ck:
+ self.assertNotEqual(ck.handle, 0)
+ SetValueEx(ck, "test_name", None, REG_DWORD, 0x80000000)
+ finally:
+ DeleteKey(HKEY_CURRENT_USER, test_key_name)
+
@unittest.skipUnless(REMOTE_NAME, "Skipping remote registry tests")
class RemoteWinregTests(BaseWinregTests):