summaryrefslogtreecommitdiff
path: root/Lib/test/test_winreg.py
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2016-12-17 13:31:58 -0800
committerSteve Dower <steve.dower@microsoft.com>2016-12-17 13:31:58 -0800
commitbbc587742719492168d250f3dcd53d82defaa0a9 (patch)
treee371fe565047782977a8afdb939e6a42b5e3a38a /Lib/test/test_winreg.py
parentec38bcb66e48bdb266e1d30ed167ab701f7dfa95 (diff)
parent40fa26606d0dc3adfa05ae4a760b3b6b189df075 (diff)
downloadcpython-git-bbc587742719492168d250f3dcd53d82defaa0a9.tar.gz
Issue #25778: winreg does not truncase string correctly (Patch by Eryk Sun)
Diffstat (limited to 'Lib/test/test_winreg.py')
-rw-r--r--Lib/test/test_winreg.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/Lib/test/test_winreg.py b/Lib/test/test_winreg.py
index d642b13f68..2be61ae15d 100644
--- a/Lib/test/test_winreg.py
+++ b/Lib/test/test_winreg.py
@@ -57,7 +57,7 @@ class BaseWinregTests(unittest.TestCase):
def delete_tree(self, root, subkey):
try:
- hkey = OpenKey(root, subkey, KEY_ALL_ACCESS)
+ hkey = OpenKey(root, subkey, 0, KEY_ALL_ACCESS)
except OSError:
# subkey does not exist
return
@@ -368,6 +368,18 @@ class LocalWinregTests(BaseWinregTests):
finally:
DeleteKey(HKEY_CURRENT_USER, test_key_name)
+ def test_read_string_containing_null(self):
+ # Test for issue 25778: REG_SZ should not contain null characters
+ try:
+ with CreateKey(HKEY_CURRENT_USER, test_key_name) as ck:
+ self.assertNotEqual(ck.handle, 0)
+ test_val = "A string\x00 with a null"
+ SetValueEx(ck, "test_name", 0, REG_SZ, test_val)
+ ret_val, ret_type = QueryValueEx(ck, "test_name")
+ self.assertEqual(ret_type, REG_SZ)
+ self.assertEqual(ret_val, "A string")
+ finally:
+ DeleteKey(HKEY_CURRENT_USER, test_key_name)
@unittest.skipUnless(REMOTE_NAME, "Skipping remote registry tests")