Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfbf0d39

Browse files
committed
mark failures
1 parent985bb8d commitfbf0d39

File tree

2 files changed

+83
-38
lines changed

2 files changed

+83
-38
lines changed

‎Lib/test/test_winreg.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,14 @@ def _test_named_args(self, key, sub_key):
212212

213213
classLocalWinregTests(BaseWinregTests):
214214

215+
# TODO: RUSTPYTHON
216+
@unittest.expectedFailure
215217
deftest_registry_works(self):
216218
self._test_all(HKEY_CURRENT_USER)
217219
self._test_all(HKEY_CURRENT_USER,"日本-subkey")
218220

221+
# TODO: RUSTPYTHON
222+
@unittest.expectedFailure
219223
deftest_registry_works_extended_functions(self):
220224
# Substitute the regular CreateKey and OpenKey calls with their
221225
# extended counterparts.
@@ -228,6 +232,8 @@ def test_registry_works_extended_functions(self):
228232

229233
self._delete_test_data(HKEY_CURRENT_USER)
230234

235+
# TODO: RUSTPYTHON
236+
@unittest.expectedFailure
231237
deftest_named_arguments(self):
232238
self._test_named_args(HKEY_CURRENT_USER,test_key_name)
233239
# Use the regular DeleteKey to clean up
@@ -245,6 +251,8 @@ def test_nonexistent_remote_registry(self):
245251
connect=lambda:ConnectRegistry("abcdefghijkl",HKEY_CURRENT_USER)
246252
self.assertRaises(OSError,connect)
247253

254+
# TODO: RUSTPYTHON
255+
@unittest.skip("flaky")
248256
deftestExpandEnvironmentStrings(self):
249257
r=ExpandEnvironmentStrings("%windir%\\test")
250258
self.assertEqual(type(r),str)
@@ -291,6 +299,8 @@ def run(self):
291299
DeleteKey(HKEY_CURRENT_USER,test_key_name+'\\changing_value')
292300
DeleteKey(HKEY_CURRENT_USER,test_key_name)
293301

302+
# TODO: RUSTPYTHON
303+
@unittest.expectedFailure
294304
deftest_long_key(self):
295305
# Issue2810, in 2.6 and 3.1 when the key name was exactly 256
296306
# characters, EnumKey raised "WindowsError: More data is
@@ -305,6 +315,8 @@ def test_long_key(self):
305315
DeleteKey(HKEY_CURRENT_USER,'\\'.join((test_key_name,name)))
306316
DeleteKey(HKEY_CURRENT_USER,test_key_name)
307317

318+
# TODO: RUSTPYTHON
319+
@unittest.expectedFailure
308320
deftest_dynamic_key(self):
309321
# Issue2810, when the value is dynamically generated, these
310322
# raise "WindowsError: More data is available" in 2.6 and 3.1
@@ -339,6 +351,8 @@ def test_reflection_unsupported(self):
339351
finally:
340352
DeleteKey(HKEY_CURRENT_USER,test_key_name)
341353

354+
# TODO: RUSTPYTHON
355+
@unittest.expectedFailure
342356
deftest_setvalueex_value_range(self):
343357
# Test for Issue #14420, accept proper ranges for SetValueEx.
344358
# Py2Reg, which gets called by SetValueEx, was using PyLong_AsLong,
@@ -351,6 +365,8 @@ def test_setvalueex_value_range(self):
351365
finally:
352366
DeleteKey(HKEY_CURRENT_USER,test_key_name)
353367

368+
# TODO: RUSTPYTHON
369+
@unittest.expectedFailure
354370
deftest_setvalueex_negative_one_check(self):
355371
# Test for Issue #43984, check -1 was not set by SetValueEx.
356372
# Py2Reg, which gets called by SetValueEx, wasn't checking return
@@ -368,6 +384,8 @@ def test_setvalueex_negative_one_check(self):
368384
finally:
369385
DeleteKey(HKEY_CURRENT_USER,test_key_name)
370386

387+
# TODO: RUSTPYTHON
388+
@unittest.expectedFailure
371389
deftest_queryvalueex_return_value(self):
372390
# Test for Issue #16759, return unsigned int from QueryValueEx.
373391
# Reg2Py, which gets called by QueryValueEx, was returning a value
@@ -384,6 +402,8 @@ def test_queryvalueex_return_value(self):
384402
finally:
385403
DeleteKey(HKEY_CURRENT_USER,test_key_name)
386404

405+
# TODO: RUSTPYTHON
406+
@unittest.expectedFailure
387407
deftest_setvalueex_crash_with_none_arg(self):
388408
# Test for Issue #21151, segfault when None is passed to SetValueEx
389409
try:
@@ -397,6 +417,8 @@ def test_setvalueex_crash_with_none_arg(self):
397417
finally:
398418
DeleteKey(HKEY_CURRENT_USER,test_key_name)
399419

420+
# TODO: RUSTPYTHON
421+
@unittest.expectedFailure
400422
deftest_read_string_containing_null(self):
401423
# Test for issue 25778: REG_SZ should not contain null characters
402424
try:
@@ -421,13 +443,16 @@ def test_remote_registry_works(self):
421443

422444
@unittest.skipUnless(WIN64_MACHINE,"x64 specific registry tests")
423445
classWin64WinregTests(BaseWinregTests):
424-
446+
# TODO: RUSTPYTHON
447+
@unittest.expectedFailure
425448
deftest_named_arguments(self):
426449
self._test_named_args(HKEY_CURRENT_USER,test_key_name)
427450
# Clean up and also exercise the named arguments
428451
DeleteKeyEx(key=HKEY_CURRENT_USER,sub_key=test_key_name,
429452
access=KEY_ALL_ACCESS,reserved=0)
430453

454+
# TODO: RUSTPYTHON
455+
@unittest.expectedFailure
431456
@unittest.skipIf(win32_edition()in ('WindowsCoreHeadless','IoTEdgeOS'),"APIs not available on WindowsCoreHeadless")
432457
deftest_reflection_functions(self):
433458
# Test that we can call the query, enable, and disable functions
@@ -513,6 +538,8 @@ def test_disable_reflection(self):
513538
DeleteKeyEx(HKEY_CURRENT_USER,test_reflect_key_name,
514539
KEY_WOW64_32KEY,0)
515540

541+
# TODO: RUSTPYTHON
542+
@unittest.expectedFailure
516543
deftest_exception_numbers(self):
517544
withself.assertRaises(FileNotFoundError)asctx:
518545
QueryValue(HKEY_CLASSES_ROOT,'some_value_that_does_not_exist')

‎vm/src/stdlib/winreg.rs

Lines changed: 55 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
usecrate::{PyRef,VirtualMachine, builtins::PyModule};
55

66
pub(crate)fnmake_module(vm:&VirtualMachine) ->PyRef<PyModule>{
7-
let module = winreg::make_module(vm);
8-
module
7+
winreg::make_module(vm)
98
}
109

1110
#[pymodule]
@@ -53,48 +52,55 @@ mod winreg {
5352
#[pyattr(once)]
5453
fnHKEY_CLASSES_ROOT(_vm:&VirtualMachine) ->PyHKEYObject{
5554
PyHKEYObject{
55+
#[allow(clippy::arc_with_non_send_sync)]
5656
hkey:Arc::new(PyRwLock::new(Registry::HKEY_CLASSES_ROOT)),
5757
}
5858
}
5959

6060
#[pyattr(once)]
6161
fnHKEY_CURRENT_USER(_vm:&VirtualMachine) ->PyHKEYObject{
6262
PyHKEYObject{
63+
#[allow(clippy::arc_with_non_send_sync)]
6364
hkey:Arc::new(PyRwLock::new(Registry::HKEY_CURRENT_USER)),
6465
}
6566
}
6667

6768
#[pyattr(once)]
6869
fnHKEY_LOCAL_MACHINE(_vm:&VirtualMachine) ->PyHKEYObject{
6970
PyHKEYObject{
71+
#[allow(clippy::arc_with_non_send_sync)]
7072
hkey:Arc::new(PyRwLock::new(Registry::HKEY_LOCAL_MACHINE)),
7173
}
7274
}
7375

7476
#[pyattr(once)]
7577
fnHKEY_USERS(_vm:&VirtualMachine) ->PyHKEYObject{
7678
PyHKEYObject{
79+
#[allow(clippy::arc_with_non_send_sync)]
7780
hkey:Arc::new(PyRwLock::new(Registry::HKEY_USERS)),
7881
}
7982
}
8083

8184
#[pyattr(once)]
8285
fnHKEY_PERFORMANCE_DATA(_vm:&VirtualMachine) ->PyHKEYObject{
8386
PyHKEYObject{
87+
#[allow(clippy::arc_with_non_send_sync)]
8488
hkey:Arc::new(PyRwLock::new(Registry::HKEY_PERFORMANCE_DATA)),
8589
}
8690
}
8791

8892
#[pyattr(once)]
8993
fnHKEY_CURRENT_CONFIG(_vm:&VirtualMachine) ->PyHKEYObject{
9094
PyHKEYObject{
95+
#[allow(clippy::arc_with_non_send_sync)]
9196
hkey:Arc::new(PyRwLock::new(Registry::HKEY_CURRENT_CONFIG)),
9297
}
9398
}
9499

95100
#[pyattr(once)]
96101
fnHKEY_DYN_DATA(_vm:&VirtualMachine) ->PyHKEYObject{
97102
PyHKEYObject{
103+
#[allow(clippy::arc_with_non_send_sync)]
98104
hkey:Arc::new(PyRwLock::new(Registry::HKEY_DYN_DATA)),
99105
}
100106
}
@@ -266,7 +272,7 @@ mod winreg {
266272
Registry::RegConnectRegistryW(
267273
wide_computer_name.as_ptr(),
268274
*key.hkey.read(),
269-
&mut ret_key
275+
&mut ret_key,
270276
)
271277
};
272278
if res ==0{
@@ -277,11 +283,7 @@ mod winreg {
277283
}else{
278284
letmut ret_key = std::ptr::null_mut();
279285
let res =unsafe{
280-
Registry::RegConnectRegistryW(
281-
std::ptr::null_mut(),
282-
*key.hkey.read(),
283-
&mut ret_key
284-
)
286+
Registry::RegConnectRegistryW(std::ptr::null_mut(),*key.hkey.read(),&mut ret_key)
285287
};
286288
if res ==0{
287289
Ok(PyHKEYObject::new(ret_key))
@@ -436,18 +438,15 @@ mod winreg {
436438
)
437439
};
438440
if rc !=0{
439-
returnErr(vm.new_os_error(format!(
440-
"RegQueryInfoKeyW failed with error code {}",
441-
rc
442-
)));
441+
returnErr(vm.new_os_error(format!("RegQueryInfoKeyW failed with error code {}", rc)));
443442
}
444-
443+
445444
// Include room for null terminators.
446445
ret_value_size +=1;
447446
ret_data_size +=1;
448447
letmut buf_value_size = ret_value_size;
449448
letmut buf_data_size = ret_data_size;
450-
449+
451450
// Allocate buffers.
452451
letmut ret_value_buf:Vec<u16> =vec![0; ret_value_sizeasusize];
453452
letmut ret_data_buf:Vec<u8> =vec![0; ret_data_sizeasusize];
@@ -484,12 +483,9 @@ mod winreg {
484483
continue;
485484
}
486485
if rc !=0{
487-
returnErr(vm.new_os_error(format!(
488-
"RegEnumValueW failed with error code {}",
489-
rc
490-
)));
486+
returnErr(vm.new_os_error(format!("RegEnumValueW failed with error code {}", rc)));
491487
}
492-
488+
493489
// At this point, current_value_size and current_data_size have been updated.
494490
// Retrieve the registry type.
495491
letmut reg_type:u32 =0;
@@ -505,25 +501,28 @@ mod winreg {
505501
&mut current_data_sizeas*mutu32,
506502
)
507503
};
508-
504+
509505
// Convert the registry value name from UTF‑16.
510506
let name_len = ret_value_buf
511507
.iter()
512508
.position(|&c| c ==0)
513509
.unwrap_or(ret_value_buf.len());
514510
let name =String::from_utf16(&ret_value_buf[..name_len])
515511
.map_err(|e| vm.new_value_error(format!("UTF16 conversion error: {}", e)))?;
516-
512+
517513
// Slice the data buffer to the actual size returned.
518514
let data_slice =&ret_data_buf[..current_data_sizeasusize];
519515
let py_data =reg_to_py(vm, data_slice, reg_type)?;
520-
516+
521517
// Return tuple (value_name, data, type)
522-
returnOk(vm.ctx.new_tuple(vec![
523-
vm.ctx.new_str(name).into(),
524-
py_data,
525-
vm.ctx.new_int(reg_type).into(),
526-
]).into());
518+
returnOk(vm
519+
.ctx
520+
.new_tuple(vec![
521+
vm.ctx.new_str(name).into(),
522+
py_data,
523+
vm.ctx.new_int(reg_type).into(),
524+
])
525+
.into());
527526
}
528527
}
529528

@@ -614,8 +613,13 @@ mod winreg {
614613
if err !=0{
615614
returnErr(vm.new_os_error(format!("error code: {}", err)));
616615
}
617-
let l:u64 =(lpftlastwritetime.dwHighDateTimeasu64) <<32 | lpftlastwritetime.dwLowDateTimeasu64;
618-
let tup:Vec<PyObjectRef> =vec![vm.ctx.new_int(lpcsubkeys).into(), vm.ctx.new_int(lpcvalues).into(), vm.ctx.new_int(l).into()];
616+
let l:u64 =(lpftlastwritetime.dwHighDateTimeasu64) <<32
617+
| lpftlastwritetime.dwLowDateTimeasu64;
618+
let tup:Vec<PyObjectRef> =vec![
619+
vm.ctx.new_int(lpcsubkeys).into(),
620+
vm.ctx.new_int(lpcvalues).into(),
621+
vm.ctx.new_int(l).into(),
622+
];
619623
Ok(vm.ctx.new_tuple(tup))
620624
}
621625

@@ -642,7 +646,11 @@ mod winreg {
642646
}
643647

644648
#[pyfunction]
645-
fnQueryValueEx(key:PyRef<PyHKEYObject>,name:String,vm:&VirtualMachine) ->PyResult<PyObjectRef>{
649+
fnQueryValueEx(
650+
key:PyRef<PyHKEYObject>,
651+
name:String,
652+
vm:&VirtualMachine,
653+
) ->PyResult<PyObjectRef>{
646654
let wide_name =to_utf16(name);
647655
letmut buf_size =0;
648656
let res =unsafe{
@@ -693,11 +701,17 @@ mod winreg {
693701
}
694702

695703
#[pyfunction]
696-
fnSetValue(key:PyRef<PyHKEYObject>,sub_key:String,typ:u32,value:String,vm:&VirtualMachine) ->PyResult<()>{
704+
fnSetValue(
705+
key:PyRef<PyHKEYObject>,
706+
sub_key:String,
707+
typ:u32,
708+
value:String,
709+
vm:&VirtualMachine,
710+
) ->PyResult<()>{
697711
if typ !=Registry::REG_SZ{
698712
returnErr(vm.new_type_error("type must be winreg.REG_SZ".to_string()));
699713
}
700-
714+
701715
let wide_sub_key =to_utf16(sub_key);
702716

703717
// TODO: Value check
@@ -753,7 +767,10 @@ mod winreg {
753767
std::slice::from_raw_parts(ret_data.as_ptr()as*constu16, u16_count)
754768
};
755769
// Only use characters up to the first NUL.
756-
let len = u16_slice.iter().position(|&c| c ==0).unwrap_or(u16_slice.len());
770+
let len = u16_slice
771+
.iter()
772+
.position(|&c| c ==0)
773+
.unwrap_or(u16_slice.len());
757774
let s =String::from_utf16(&u16_slice[..len])
758775
.map_err(|e| vm.new_value_error(format!("UTF16 error: {}", e)))?;
759776
Ok(vm.ctx.new_str(s).into())
@@ -814,10 +831,11 @@ mod winreg {
814831
}
815832
// REG_SZ is fallthrough
816833
REG_EXPAND_SZ =>{
817-
returnErr(vm.new_type_error("TODO: RUSTPYTHON REG_EXPAND_SZ is not supported".to_string()));
834+
Err(vm
835+
.new_type_error("TODO: RUSTPYTHON REG_EXPAND_SZ is not supported".to_string()))
818836
}
819837
REG_MULTI_SZ =>{
820-
returnErr(vm.new_type_error("TODO: RUSTPYTHON REG_MULTI_SZ is not supported".to_string()));
838+
Err(vm.new_type_error("TODO: RUSTPYTHON REG_MULTI_SZ is not supported".to_string()))
821839
}
822840
// REG_BINARY is fallthrough
823841
_ =>{
@@ -856,7 +874,7 @@ mod winreg {
856874
if res !=0{
857875
returnErr(vm.new_os_error(format!("error code: {}", res)));
858876
}
859-
},
877+
}
860878
Ok(None) =>{
861879
let len =0;
862880
let ptr = std::ptr::null();
@@ -874,7 +892,7 @@ mod winreg {
874892
if res !=0{
875893
returnErr(vm.new_os_error(format!("error code: {}", res)));
876894
}
877-
},
895+
}
878896
Err(_) =>returnErr(vm.new_type_error("value must be an integer".to_string())),
879897
}
880898
Ok(())

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp