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

Skip to content

Commit 4482b01

Browse files
committed
Merge 3.3
2 parents 6e5c8f9 + 62cf69e commit 4482b01

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
@@ -10,6 +10,9 @@ What's New in Python 3.4.0 Alpha 1?
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #14420: Support the full DWORD (unsigned long) range in Py2Reg
14+
when passed a REG_DWORD value. Fixes OverflowError in winreg.SetValueEx.
15+
1316
- Issue #11939: Set the st_dev attribute of stat_result to allow Windows to
1417
take advantage of the os.path.samefile/sameopenfile/samestat implementations
1518
used by other platforms.

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)