@@ -57,7 +57,7 @@ def setUp(self):
5757
5858 def delete_tree (self , root , subkey ):
5959 try :
60- hkey = OpenKey (root , subkey , KEY_ALL_ACCESS )
60+ hkey = OpenKey (root , subkey , 0 , KEY_ALL_ACCESS )
6161 except OSError :
6262 # subkey does not exist
6363 return
@@ -368,6 +368,18 @@ def test_setvalueex_crash_with_none_arg(self):
368368 finally :
369369 DeleteKey (HKEY_CURRENT_USER , test_key_name )
370370
371+ def test_read_string_containing_null (self ):
372+ # Test for issue 25778: REG_SZ should not contain null characters
373+ try :
374+ with CreateKey (HKEY_CURRENT_USER , test_key_name ) as ck :
375+ self .assertNotEqual (ck .handle , 0 )
376+ test_val = "A string\x00 with a null"
377+ SetValueEx (ck , "test_name" , 0 , REG_SZ , test_val )
378+ ret_val , ret_type = QueryValueEx (ck , "test_name" )
379+ self .assertEqual (ret_type , REG_SZ )
380+ self .assertEqual (ret_val , "A string" )
381+ finally :
382+ DeleteKey (HKEY_CURRENT_USER , test_key_name )
371383
372384
373385@unittest .skipUnless (REMOTE_NAME , "Skipping remote registry tests" )
0 commit comments