Skip to content

Commit 876368e

Browse files
authored
windows umask, win32_xstat_slow_impl, fake EXT_SUFFIX (RustPython#6340)
* umask * EXT_SUFFIX * File Attributes and win32_xstat_slow_impl * unmark tests
1 parent cab41c8 commit 876368e

File tree

8 files changed

+436
-104
lines changed

8 files changed

+436
-104
lines changed

.cspell.dict/cpython.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ prec
4646
preinitialized
4747
PYTHREAD_NAME
4848
SA_ONSTACK
49+
SOABI
4950
stackdepth
5051
stringlib
5152
structseq

Lib/test/test_genericpath.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -352,13 +352,6 @@ def test_invalid_paths(self):
352352
with self.assertRaisesRegex(ValueError, 'embedded null'):
353353
func(b'/tmp\x00abcds')
354354

355-
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON')
356-
def test_samestat_on_symlink(self):
357-
return super().test_samestat_on_symlink()
358-
359-
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON')
360-
def test_samefile_on_symlink(self):
361-
return super().test_samefile_on_symlink()
362355

363356
# Following TestCase is not supposed to be run from test_genericpath.
364357
# It is inherited by other test modules (ntpath, posixpath).

Lib/test/test_logging.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6384,7 +6384,6 @@ def rotator(source, dest):
63846384
rh.close()
63856385

63866386
class TimedRotatingFileHandlerTest(BaseFileTest):
6387-
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON')
63886387
@unittest.skipIf(support.is_wasi, "WASI does not have /dev/null.")
63896388
def test_should_not_rollover(self):
63906389
# See bpo-45401. Should only ever rollover regular files

Lib/test/test_ntpath.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,8 +1458,6 @@ def test_isfile_named_pipe(self):
14581458
finally:
14591459
_winapi.CloseHandle(h)
14601460

1461-
# TODO: RUSTPYTHON
1462-
@unittest.expectedFailure
14631461
@unittest.skipIf(sys.platform != 'win32', "windows only")
14641462
def test_con_device(self):
14651463
self.assertFalse(os.path.isfile(r"\\.\CON"))
@@ -1527,14 +1525,6 @@ def test_expandvars(self):
15271525
def test_expandvars_nonascii(self):
15281526
return super().test_expandvars_nonascii()
15291527

1530-
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON')
1531-
def test_samefile_on_symlink(self):
1532-
return super().test_samefile_on_symlink()
1533-
1534-
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON')
1535-
def test_samestat_on_symlink(self):
1536-
return super().test_samestat_on_symlink()
1537-
15381528

15391529
class PathLikeTests(NtpathTestCase):
15401530

Lib/test/test_shutil.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,7 +1476,6 @@ def test_dont_copy_file_onto_link_to_itself(self):
14761476
finally:
14771477
shutil.rmtree(TESTFN, ignore_errors=True)
14781478

1479-
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; AssertionError: SameFileError not raised for copyfile')
14801479
@os_helper.skip_unless_symlink
14811480
def test_dont_copy_file_onto_symlink_to_itself(self):
14821481
# bug 851123.
@@ -2577,7 +2576,6 @@ def test_destinsrc_false_positive(self):
25772576
finally:
25782577
os_helper.rmtree(TESTFN)
25792578

2580-
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
25812579
@os_helper.skip_unless_symlink
25822580
@mock_rename
25832581
def test_move_file_symlink(self):
@@ -2587,7 +2585,6 @@ def test_move_file_symlink(self):
25872585
self.assertTrue(os.path.islink(self.dst_file))
25882586
self.assertTrue(os.path.samefile(self.src_file, self.dst_file))
25892587

2590-
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
25912588
@os_helper.skip_unless_symlink
25922589
@mock_rename
25932590
def test_move_file_symlink_to_dir(self):
@@ -2611,7 +2608,6 @@ def test_move_dangling_symlink(self):
26112608
self.assertTrue(os.path.islink(dst_link))
26122609
self.assertEqual(os.path.realpath(src), os.path.realpath(dst_link))
26132610

2614-
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
26152611
@os_helper.skip_unless_symlink
26162612
@mock_rename
26172613
def test_move_dir_symlink(self):
@@ -2687,12 +2683,10 @@ def _test_move_symlink_to_dir_into_dir(self, dst):
26872683
self.assertTrue(os.path.samefile(self.dst_dir, dst_link))
26882684
self.assertTrue(os.path.exists(src))
26892685

2690-
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
26912686
@os_helper.skip_unless_symlink
26922687
def test_move_symlink_to_dir_into_dir(self):
26932688
self._test_move_symlink_to_dir_into_dir(self.dst_dir)
26942689

2695-
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
26962690
@os_helper.skip_unless_symlink
26972691
def test_move_symlink_to_dir_into_symlink_to_dir(self):
26982692
dst = os.path.join(self.src_dir, 'otherlinktodir')

crates/vm/src/stdlib/nt.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,20 @@ pub(crate) mod module {
475475
Ok(())
476476
}
477477

478+
unsafe extern "C" {
479+
fn _umask(mask: i32) -> i32;
480+
}
481+
482+
#[pyfunction]
483+
fn umask(mask: i32, vm: &VirtualMachine) -> PyResult<i32> {
484+
let result = unsafe { _umask(mask) };
485+
if result < 0 {
486+
Err(errno_err(vm))
487+
} else {
488+
Ok(result)
489+
}
490+
}
491+
478492
pub(crate) fn support_funcs() -> Vec<SupportFunc> {
479493
Vec::new()
480494
}

crates/vm/src/stdlib/sysconfig.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,19 @@ pub(crate) mod sysconfig {
77
#[pyfunction]
88
fn config_vars(vm: &VirtualMachine) -> PyDictRef {
99
let vars = vm.ctx.new_dict();
10+
11+
// FIXME: This is an entirely wrong implementation of EXT_SUFFIX.
12+
// EXT_SUFFIX must be a string starting with "." for pip compatibility
13+
// Using ".pyd" causes pip's _generic_abi() to fall back to _cpython_abis()
14+
vars.set_item("EXT_SUFFIX", ".pyd".to_pyobject(vm), vm)
15+
.unwrap();
16+
vars.set_item("SOABI", vm.ctx.none(), vm).unwrap();
17+
1018
vars.set_item("Py_GIL_DISABLED", true.to_pyobject(vm), vm)
1119
.unwrap();
20+
vars.set_item("Py_DEBUG", false.to_pyobject(vm), vm)
21+
.unwrap();
22+
1223
vars
1324
}
1425
}

0 commit comments

Comments
 (0)