diff options
author | Brian Curtin <brian@python.org> | 2012-12-27 20:06:38 (GMT) |
---|---|---|
committer | Brian Curtin <brian@python.org> | 2012-12-27 20:06:38 (GMT) |
commit | f8704fb24ef547b066e43f81d0e2e3f4ca427296 (patch) | |
tree | fb315b5d1cb3e44de151958080ab5a694a135a72 | |
parent | 4482b01d2308bd089546fc9cdffe613a54e15307 (diff) | |
parent | e6bfa2911ad061c664fdd09515a32c52e18b871c (diff) | |
download | cpython-f8704fb24ef547b066e43f81d0e2e3f4ca427296.zip cpython-f8704fb24ef547b066e43f81d0e2e3f4ca427296.tar.gz cpython-f8704fb24ef547b066e43f81d0e2e3f4ca427296.tar.bz2 |
Merge 3.3
-rw-r--r-- | Lib/test/test_winreg.py | 17 | ||||
-rw-r--r-- | Misc/NEWS | 4 | ||||
-rw-r--r-- | PC/winreg.c | 4 |
3 files changed, 23 insertions, 2 deletions
diff --git a/Lib/test/test_winreg.py b/Lib/test/test_winreg.py index c154134..a8454a0 100644 --- a/Lib/test/test_winreg.py +++ b/Lib/test/test_winreg.py @@ -335,6 +335,23 @@ class LocalWinregTests(BaseWinregTests): finally: DeleteKey(HKEY_CURRENT_USER, test_key_name) + def test_queryvalueex_return_value(self): + # Test for Issue #16759, return unsigned int from QueryValueEx. + # Reg2Py, which gets called by QueryValueEx, was returning a value + # generated by PyLong_FromLong. The implmentation now uses + # PyLong_FromUnsignedLong to match DWORD's size. + try: + with CreateKey(HKEY_CURRENT_USER, test_key_name) as ck: + self.assertNotEqual(ck.handle, 0) + test_val = 0x80000000 + SetValueEx(ck, "test_name", None, REG_DWORD, test_val) + ret_val, ret_type = QueryValueEx(ck, "test_name") + self.assertEqual(ret_type, REG_DWORD) + self.assertEqual(ret_val, test_val) + finally: + DeleteKey(HKEY_CURRENT_USER, test_key_name) + + @unittest.skipUnless(REMOTE_NAME, "Skipping remote registry tests") class RemoteWinregTests(BaseWinregTests): @@ -10,6 +10,10 @@ What's New in Python 3.4.0 Alpha 1? Core and Builtins ----------------- +- Issue #16759: Support the full DWORD (unsigned long) range in Reg2Py + when retreiving a REG_DWORD value. This corrects functions like + winreg.QueryValueEx that may have been returning truncated values. + - Issue #14420: Support the full DWORD (unsigned long) range in Py2Reg when passed a REG_DWORD value. Fixes OverflowError in winreg.SetValueEx. diff --git a/PC/winreg.c b/PC/winreg.c index 08f6b5e..a2511d5 100644 --- a/PC/winreg.c +++ b/PC/winreg.c @@ -912,9 +912,9 @@ Reg2Py(BYTE *retDataBuf, DWORD retDataSize, DWORD typ) switch (typ) { case REG_DWORD: if (retDataSize == 0) - obData = PyLong_FromLong(0); + obData = PyLong_FromUnsignedLong(0); else - obData = PyLong_FromLong(*(int *)retDataBuf); + obData = PyLong_FromUnsignedLong(*(int *)retDataBuf); break; case REG_SZ: case REG_EXPAND_SZ: |