Skip to content

Fix test_path_like_objects#4773

Merged
youknowone merged 3 commits into
RustPython:mainfrom
jiwahn:test_path_like_objects
Jun 12, 2023
Merged

Fix test_path_like_objects#4773
youknowone merged 3 commits into
RustPython:mainfrom
jiwahn:test_path_like_objects

Conversation

@jiwahn
Copy link
Copy Markdown
Contributor

@jiwahn jiwahn commented Mar 26, 2023

add support for FsPath

Comment thread Lib/test/test_compile.py Outdated
@jiwahn jiwahn force-pushed the test_path_like_objects branch from 6d9b839 to 63dbdca Compare March 26, 2023 01:42
Comment thread vm/src/stdlib/os.rs Outdated
Comment on lines +189 to +194
pub fn as_str(&self) -> &str {
match self {
FsPath::Bytes(b) => std::str::from_utf8(b).unwrap(),
FsPath::Str(s) => s.as_str(),
}
}
Copy link
Copy Markdown
Member

@youknowone youknowone Mar 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since FsPath is intended to obtain OsString in Rust side, I am opposed to add as_str like this signature here.

My suggestion is adding

fn to_os_string(&self) -> std::os::OsString

and use it from fn compile.

Not this case, but even if we need to implement as_str(), it will look like:

pub fn as_str(&self) -> Result<&str, Utf8Error>

@youknowone
Copy link
Copy Markdown
Member

Oh, FsPath is placed in os.rs but it is not compiled for wasm.
relocating them to a new file vm/src/function/fspath.rs or vm/src/function/mod.rs will be helpful.

@youknowone youknowone added A-stdlib z-ca-2023 Tag to track contrubution-academy 2023 labels Mar 26, 2023
@jiwahn jiwahn closed this Mar 26, 2023
@jiwahn jiwahn deleted the test_path_like_objects branch March 26, 2023 06:40
@youknowone
Copy link
Copy Markdown
Member

@ilp-sys Hi, is this accidently closed? could you open it again?

@jiwahn jiwahn restored the test_path_like_objects branch March 26, 2023 09:46
@jiwahn
Copy link
Copy Markdown
Contributor Author

jiwahn commented Mar 26, 2023

I must have done something wrong with the git cli, reopened it .

@youknowone
Copy link
Copy Markdown
Member

I found refactoring FsPath is more complex issue than it looks like. Let me look in more for a few more days.

@youknowone
Copy link
Copy Markdown
Member

@ilp-sys #4782 is finally done! Could you please rebase this patch? I think removing the last commit will make the other 2 commits be rebase without conflict. And not that much changes will be needed.

@jiwahn jiwahn force-pushed the test_path_like_objects branch from 17ea73a to 37b7f01 Compare March 31, 2023 02:40
@youknowone
Copy link
Copy Markdown
Member

test_basic_script_with_path_object is also succsesful

@DimitrisJim DimitrisJim force-pushed the test_path_like_objects branch from 37b7f01 to 7262616 Compare June 12, 2023 12:54
@DimitrisJim DimitrisJim dismissed youknowone’s stale review June 12, 2023 13:32

Addressed review.

Copy link
Copy Markdown
Member

@youknowone youknowone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@youknowone youknowone merged commit 8dbf7b2 into RustPython:main Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-stdlib z-ca-2023 Tag to track contrubution-academy 2023

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants