[Python-checkins] cpython (merge 3.3 -> default): Merge 3.3
brian.curtin
python-checkins at python.org
Thu Dec 27 17:31:00 CET 2012
http://hg.python.org/cpython/rev/8a70fe99151c
changeset: 81085:8a70fe99151c
parent: 81081:eae2a42603ee
parent: 81084:94a76b49dc69
user: Brian Curtin <brian at python.org>
date: Thu Dec 27 10:15:54 2012 -0600
summary:
Merge 3.3
files:
Lib/test/test_winreg.py | 12 ++++++++++++
Misc/NEWS | 3 +++
PC/winreg.c | 2 +-
3 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/Lib/test/test_winreg.py b/Lib/test/test_winreg.py
--- a/Lib/test/test_winreg.py
+++ b/Lib/test/test_winreg.py
@@ -323,6 +323,18 @@
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):
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
Core and Builtins
-----------------
+- Issue #14420: Support the full DWORD (unsigned long) range in Py2Reg
+ when passed a REG_DWORD value. Fixes OverflowError in winreg.SetValueEx.
+
- Issue #11939: Set the st_dev attribute of stat_result to allow Windows to
take advantage of the os.path.samefile/sameopenfile/samestat implementations
used by other platforms.
diff --git a/PC/winreg.c b/PC/winreg.c
--- a/PC/winreg.c
+++ b/PC/winreg.c
@@ -785,7 +785,7 @@
memcpy(*retDataBuf, &zero, sizeof(DWORD));
}
else {
- DWORD d = PyLong_AsLong(value);
+ DWORD d = PyLong_AsUnsignedLong(value);
memcpy(*retDataBuf, &d, sizeof(DWORD));
}
break;
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list