summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_winreg.py
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2016-12-17 21:30:27 (GMT)
committerSteve Dower <steve.dower@microsoft.com>2016-12-17 21:30:27 (GMT)
commit40fa26606d0dc3adfa05ae4a760b3b6b189df075 (patch)
tree6a6277e78afd66109dc6567916cc43cc35a0507d /Lib/test/test_winreg.py
parentce042af3fe1ee64e34d5c31874011ed663baeb2a (diff)
downloadcpython-40fa26606d0dc3adfa05ae4a760b3b6b189df075.zip
cpython-40fa26606d0dc3adfa05ae4a760b3b6b189df075.tar.gz
cpython-40fa26606d0dc3adfa05ae4a760b3b6b189df075.tar.bz2
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 d642b13..2be61ae 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")