Skip to content

Reorganize os module #2041

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 1, 2020
Merged

Reorganize os module #2041

merged 2 commits into from
Aug 1, 2020

Conversation

youknowone
Copy link
Member

@youknowone youknowone commented Jul 29, 2020

This PR re-cluster os module with 3 submodules posix, nt and minor.
I think current result is not the ideal state but this was limit for me due to lack of windows dev enviroment.

@youknowone youknowone force-pushed the os-module branch 5 times, most recently from f57f697 to 7b2441e Compare July 29, 2020 21:07
@youknowone youknowone marked this pull request as ready for review July 30, 2020 04:03
Copy link
Member

@coolreader18 coolreader18 left a comment

Choose a reason for hiding this comment

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

LGTM, is there any concern about span info being lost or was that fixed with rust 1.45 and proc_macro_hygiene?

@youknowone
Copy link
Member Author

Sorry, I am not aware of that topic at all. Is it a debug info problem or could it make an actual bug?

@coolreader18
Copy link
Member

coolreader18 commented Jul 31, 2020

I'm not sure exactly, I haven't actually seen an issue for it in rust-lang/rust, but there was some stuff in the latest version related to proc macros. Does the issue with error locations not showing up still happen (#1832 (comment))?

@youknowone
Copy link
Member Author

youknowone commented Jul 31, 2020

When signature is wrong,

for pyfunction:

(RustPython) ➜  RustPython git:(master) ✗ cargo build
    Blocking waiting for file lock on build directory
   Compiling rustpython-vm v0.1.2 (//RustPython/vm)
error[E0277]: the trait bound `for<'r> fn(&'r vm::VirtualMachine, function::OptionalArg<pyobject::PyRef<obj::objstr::PyString>>) -> std::result::Result<std::sync::Arc<pyobject::PyObject<(dyn pyobject::PyObjectPayload + 'static)>>, pyobject::PyRef<exceptions::PyBaseException>> {stdlib::os::_os::error}: function::IntoPyNativeFunc<_, _, _>` is not satisfied
   --> vm/src/stdlib/os.rs:277:8
    |
277 |     fn error(vm: &VirtualMachine, message: OptionalArg<PyStringRef>) -> PyResult {
    |        ^^^^^ the trait `function::IntoPyNativeFunc<_, _, _>` is not implemented for `for<'r> fn(&'r vm::VirtualMachine, function::OptionalArg<pyobject::PyRef<obj::objstr::PyString>>) -> std::result::Result<std::sync::Arc<pyobject::PyObject<(dyn pyobject::PyObjectPayload + 'static)>>, pyobject::PyRef<exceptions::PyBaseException>> {stdlib::os::_os::error}`

error: aborting due to previous error

For inner class method:

(RustPython) ➜  RustPython git:(master) ✗ cargo build
    Blocking waiting for file lock on build directory
   Compiling rustpython-vm v0.1.2 (//RustPython/vm)
error[E0277]: the trait bound `for<'r> fn(stdlib::os::_os::DirEntry, stdlib::os::FollowSymlinks, &'r vm::VirtualMachine) -> std::result::Result<bool, pyobject::PyRef<exceptions::PyBaseException>> {stdlib::os::_os::DirEntry::is_dir}: function::IntoPyNativeFunc<_, _, _>` is not satisfied
   --> vm/src/stdlib/os.rs:435:12
    |
435 |         fn is_dir(self, follow_symlinks: FollowSymlinks, vm: &VirtualMachine) -> PyResult<bool> {
    |            ^^^^^^ the trait `function::IntoPyNativeFunc<_, _, _>` is not implemented for `for<'r> fn(stdlib::os::_os::DirEntry, stdlib::os::FollowSymlinks, &'r vm::VirtualMachine) -> std::result::Result<bool, pyobject::PyRef<exceptions::PyBaseException>> {stdlib::os::_os::DirEntry::is_dir}`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
error: could not compile `rustpython-vm`.

To learn more, run the command again with --verbose.

Calling the function out of the module:

(RustPython) ➜  RustPython git:(master) ✗ cargo build
    Blocking waiting for file lock on build directory
   Compiling rustpython-vm v0.1.2 (/Users/youknowone/Projects/RustPython/vm)
error[E0308]: mismatched types
   --> vm/src/stdlib/io.rs:630:25
    |
630 |                         &os::PyPathLike::new_str(name.as_str().to_owned()),
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |                         |
    |                         expected struct `stdlib::os::PyPathLike`, found `&stdlib::os::PyPathLike`
    |                         help: consider removing the borrow: `os::PyPathLike::new_str(name.as_str().to_owned())`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
error: could not compile `rustpython-vm`.

To learn more, run the command again with --verbose.

I have no idea what kind of error was in that comment. To be honest, I didn't have any serious problem while working with pymodule. so I am afraid I am not a suitable person to say this is happening or not.

@youknowone
Copy link
Member Author

@palaviv any idea how to make the untrackable error?

@youknowone
Copy link
Member Author

Go for this and let's see how things go. Even when it has problem, it doesn't look commonly making very serious issue, and it will be eventually solved by rust itself.

@youknowone youknowone merged commit 8dccb60 into RustPython:master Aug 1, 2020
@youknowone youknowone deleted the os-module branch August 1, 2020 14:59
@youknowone
Copy link
Member Author

youknowone commented Aug 23, 2020

Oh, I found it. nested macro expanding or errors in generated code makes the error messages weird

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants