Skip to content

Commit 6fd5ee7

Browse files
committed
fix
1 parent a6f53a3 commit 6fd5ee7

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

crates/vm/src/stdlib/_winapi.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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)?;

src/settings.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,13 @@ pub fn parse_opts() -> Result<(Settings, RunMode), lexopt::Error> {
260260

261261
settings.check_hash_pycs_mode = args.check_hash_based_pycs;
262262

263-
if let Some(val) = get_env("PYTHONUTF8") {
264-
settings.utf8_mode = match val.to_str() {
265-
Some("1") | Some("") => 1,
266-
Some("0") => 0,
263+
if let Some(val) = get_env("PYTHONUTF8")
264+
&& let Some(val_str) = val.to_str()
265+
&& !val_str.is_empty()
266+
{
267+
settings.utf8_mode = match val_str {
268+
"1" => 1,
269+
"0" => 0,
267270
_ => {
268271
error!(
269272
"Fatal Python error: config_init_utf8_mode: \

0 commit comments

Comments
 (0)