@@ -1160,7 +1160,7 @@ mod _winapi {
11601160 initial_state : bool ,
11611161 name : Option < PyStrRef > ,
11621162 vm : & VirtualMachine ,
1163- ) -> PyResult < Option < WinHandle > > {
1163+ ) -> PyResult < WinHandle > {
11641164 use windows_sys:: Win32 :: System :: Threading :: CreateEventW as WinCreateEventW ;
11651165
11661166 let _ = security_attributes; // Ignored, always NULL
@@ -1181,7 +1181,7 @@ mod _winapi {
11811181 return Err ( vm. new_last_os_error ( ) ) ;
11821182 }
11831183
1184- Ok ( Some ( WinHandle ( handle) ) )
1184+ Ok ( WinHandle ( handle) )
11851185 }
11861186
11871187 /// SetEvent - Set the specified event object to the signaled state.
@@ -1961,6 +1961,7 @@ mod _winapi {
19611961 if err != 0 {
19621962 return Err ( vm. new_os_error ( err as i32 ) ) ;
19631963 }
1964+ scopeguard:: defer! { unsafe { RegCloseKey ( hkcr) } ; }
19641965
19651966 let mut i: u32 = 0 ;
19661967 let mut entries: Vec < ( String , String ) > = Vec :: new ( ) ;
@@ -2007,7 +2008,6 @@ mod _winapi {
20072008 continue ;
20082009 }
20092010 if err != 0 {
2010- unsafe { RegCloseKey ( hkcr) } ;
20112011 return Err ( vm. new_os_error ( err as i32 ) ) ;
20122012 }
20132013
@@ -2051,8 +2051,6 @@ mod _winapi {
20512051 }
20522052 }
20532053
2054- unsafe { RegCloseKey ( hkcr) } ;
2055-
20562054 // Process remaining entries
20572055 for ( mime_type, ext) in entries {
20582056 on_type_read. call ( ( vm. ctx . new_str ( mime_type) , vm. ctx . new_str ( ext) ) , vm) ?;
0 commit comments