Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 62cf69e

Browse files
committed
Merge 3.2
2 parents 6f52027 + 12706f2 commit 62cf69e

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

Lib/test/test_winreg.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,18 @@ def test_reflection_unsupported(self):
323323
finally:
324324
DeleteKey(HKEY_CURRENT_USER, test_key_name)
325325

326+
def test_setvalueex_value_range(self):
327+
# Test for Issue #14420, accept proper ranges for SetValueEx.
328+
# Py2Reg, which gets called by SetValueEx, was using PyLong_AsLong,
329+
# thus raising OverflowError. The implementation now uses
330+
# PyLong_AsUnsignedLong to match DWORD's size.
331+
try:
332+
with CreateKey(HKEY_CURRENT_USER, test_key_name) as ck:
333+
self.assertNotEqual(ck.handle, 0)
334+
SetValueEx(ck, "test_name", None, REG_DWORD, 0x80000000)
335+
finally:
336+
DeleteKey(HKEY_CURRENT_USER, test_key_name)
337+
326338

327339
@unittest.skipUnless(REMOTE_NAME, "Skipping remote registry tests")
328340
class RemoteWinregTests(BaseWinregTests):

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ What's New in Python 3.3.1?
1212
Core and Builtins
1313
-----------------
1414

15+
- Issue #14420: Support the full DWORD (unsigned long) range in Py2Reg
16+
when passed a REG_DWORD value. Fixes OverflowError in winreg.SetValueEx.
17+
1518
- Issue #16597: In buffered and text IO, call close() on the underlying stream
1619
if invoking flush() fails.
1720

PC/winreg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize)
785785
memcpy(*retDataBuf, &zero, sizeof(DWORD));
786786
}
787787
else {
788-
DWORD d = PyLong_AsLong(value);
788+
DWORD d = PyLong_AsUnsignedLong(value);
789789
memcpy(*retDataBuf, &d, sizeof(DWORD));
790790
}
791791
break;

0 commit comments

Comments
 (0)