Make OSError subclass instead of itself#2960
Conversation
| }; | ||
| } | ||
|
|
||
| macro_rules! extends_os_error { |
There was a problem hiding this comment.
I dont' think we need an own macro for this error. We can write it without macro or using new macro #2897
There was a problem hiding this comment.
I need to use tp_new for OSError itself. So I will change it without macro.
|
@sobolevn Could you look into this PR? This PR is a sort of use case of exception macro. It maybe helpful to give you an idea to decide to choose one. |
sobolevn
left a comment
There was a problem hiding this comment.
Looks like that this use-case fits perfectly into
RustPython/vm/src/exceptions.rs
Lines 646 to 657 in c57285b
We can re-assign slots with it, but it needs a little polish.
I will send a PR soon! Later we can rebase this one and merge it 👍
Thanks!
# Conflicts: # vm/src/exceptions.rs
# Conflicts: # Cargo.lock # vm/src/exceptions.rs
| fn base_exception_new(cls: PyTypeRef, args: FuncArgs, vm: &VirtualMachine) -> PyResult { | ||
| PyBaseException::slot_new(cls, args, vm) | ||
| } |
There was a problem hiding this comment.
if these methods are not required to be moved, keep them on the original place. they will be put in impl later once we revise pyexception macro
There was a problem hiding this comment.
They are used in define_macro.
There was a problem hiding this comment.
I agree it is used. I don't see a good reason why it need to be moved to here. I checked out the code and tried to compile it without moving this function. I couldn't see any problem.
There was a problem hiding this comment.
I see. I moved functions just for distinguishing functions and macros. For readability, if you want not moving the functions I can revert that.
| #[cfg(feature = "rustpython-compiler")] | ||
| pub use rustpython_compiler as compile; | ||
|
|
||
| use crate::stdlib::errno::errors; |
There was a problem hiding this comment.
why is this module imported here? I expect this is imported from os_error_optional_new.
| fn base_exception_new(cls: PyTypeRef, args: FuncArgs, vm: &VirtualMachine) -> PyResult { | ||
| PyBaseException::slot_new(cls, args, vm) | ||
| } |
There was a problem hiding this comment.
I agree it is used. I don't see a good reason why it need to be moved to here. I checked out the code and tried to compile it without moving this function. I couldn't see any problem.
8d96a6b to
a504a74
Compare
7a2eb2a to
d913c45
Compare
aa3beda to
7f8562a
Compare
|
Thank you for contributing! Instead of merge, please try to use rebase next time. |
This PR will fix #2914.