summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBrian Curtin <brian@python.org>2012-12-27 18:28:51 (GMT)
committerBrian Curtin <brian@python.org>2012-12-27 18:28:51 (GMT)
commit0e091b036503adc1c46022dbf974bb2f64ceed17 (patch)
tree2e47287764237b50e3f92654adc01c78dffc774d /Lib
parent4a5a4c28085910c6a40e40f01d763d55f5190e38 (diff)
downloadcpython-0e091b036503adc1c46022dbf974bb2f64ceed17.zip
cpython-0e091b036503adc1c46022dbf974bb2f64ceed17.tar.gz
cpython-0e091b036503adc1c46022dbf974bb2f64ceed17.tar.bz2
Fix #14420. Check for PyLong as well as PyInt when converting in Py2Reg.
This fixes a ValueError seen in winreg.SetValueEx when passed long winreg.REG_DWORD values that should be supported by the underlying API.
Diffstat (limited to 'Lib')
-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 a741b65..c4ae737 100644
--- a/Lib/test/test_winreg.py
+++ b/Lib/test/test_winreg.py
@@ -314,6 +314,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):