Skip to content

Commit a484ba4

Browse files
authored
st_file_attributes (RustPython#6353)
1 parent abc5c22 commit a484ba4

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

Lib/test/test_os.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,6 @@ def check_file_attributes(self, result):
714714
self.assertTrue(isinstance(result.st_file_attributes, int))
715715
self.assertTrue(0 <= result.st_file_attributes <= 0xFFFFFFFF)
716716

717-
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; os.stat return value doesnt have st_file_attributes attribute')
718717
@unittest.skipUnless(sys.platform == "win32",
719718
"st_file_attributes is Win32 specific")
720719
def test_file_attributes(self):

Lib/test/test_site.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ def test_addsitedir_hidden_flags(self):
223223
finally:
224224
pth_file.cleanup()
225225

226-
@unittest.expectedFailure # TODO: RUSTPYTHON
227226
@unittest.skipUnless(sys.platform == 'win32', 'test needs Windows')
228227
@support.requires_subprocess()
229228
def test_addsitedir_hidden_file_attribute(self):

crates/vm/src/stdlib/os.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,9 @@ pub(super) mod _os {
801801
#[pyarg(any, default)]
802802
#[pystruct_sequence(skip)]
803803
pub st_reparse_tag: u32,
804+
#[pyarg(any, default)]
805+
#[pystruct_sequence(skip)]
806+
pub st_file_attributes: u32,
804807
}
805808

806809
impl StatResultData {
@@ -835,6 +838,11 @@ pub(super) mod _os {
835838
#[cfg(not(windows))]
836839
let st_reparse_tag = 0;
837840

841+
#[cfg(windows)]
842+
let st_file_attributes = stat.st_file_attributes;
843+
#[cfg(not(windows))]
844+
let st_file_attributes = 0;
845+
838846
Self {
839847
st_mode: vm.ctx.new_pyref(stat.st_mode),
840848
st_ino: vm.ctx.new_pyref(stat.st_ino),
@@ -853,6 +861,7 @@ pub(super) mod _os {
853861
st_mtime_ns: to_ns(mtime),
854862
st_ctime_ns: to_ns(ctime),
855863
st_reparse_tag,
864+
st_file_attributes,
856865
}
857866
}
858867
}

0 commit comments

Comments
 (0)