You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Exception.__init__.__qualname__ is incorrectly set to 'BaseException.__init__' #2771
Python 3.9.4 (default, Apr 5 2021, 01:47:16)
[Clang 11.0.0 (clang-1100.0.33.17)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> Exception.__init__.__qualname__
'Exception.__init__'
RustPython:
Welcome to the magnificent Rust Python 0.1.2 interpreter 😱 🖖
>>>>> Exception.__init__.__qualname__
'BaseException.__init__'
Currently CPython uses three macros to define different Exception types:
SimpleExtendsException
MiddlingExtendsException
ComplexExtendsException
These macros copies different parts of BaseException attributes. Like (initproc)BaseException_init for SimpleExtendsException which is the root cause for this specific bugreport.
I am also planning to write macros to match the CPython implementation.
Does this sound ok?
While we call create_exception_type all .attributes are not yet set (default is {}). But, we need to copy things like __init__ at some point. The other opportunity is when we call extend_class!, but not all exception types are extended. I don't see any other places where this can be done.
So, I was planning to replace extend_class! calls here:
it seems I didn't catch your idea yet. are you planning to make something like #[pyexception] like #[pyclass]? or richer version of extend_class!?
If we need them to implement things, we need it. SimpleExtendsException looked like somewhat we already had to me, but maybe i overlooked the features of them.
Activity
sobolevn commentedon Aug 1, 2021
I am working right now on this problem.
I also need to test this case:
sobolevn commentedon Aug 12, 2021
Currently CPython uses three macros to define different Exception types:
These macros copies different parts of
BaseExceptionattributes. Like(initproc)BaseException_initforSimpleExtendsExceptionwhich is the root cause for this specific bugreport.I am also planning to write macros to match the CPython implementation.
Does this sound ok?
youknowone commentedon Aug 12, 2021
writing functions to match CPython macros, right?
I think we already have similar functions.
adding a doc parameter to
create_exception_typewill be same asSimpleExtendsException.adding a few more for specific usage will be good.
sobolevn commentedon Aug 12, 2021
Ok, so, here's my take on this problem.
While we call
create_exception_typeall.attributesare not yet set (default is{}). But, we need to copy things like__init__at some point. The other opportunity is when we callextend_class!, but not all exception types are extended. I don't see any other places where this can be done.So, I was planning to replace
extend_class!calls here:RustPython/vm/src/exceptions.rs
Lines 686 to 750 in 8cf3506
ExceptionZooare covered by these macroses.Thoughts?
youknowone commentedon Aug 12, 2021
it seems I didn't catch your idea yet. are you planning to make something like
#[pyexception]like#[pyclass]? or richer version ofextend_class!?If we need them to implement things, we need it.
SimpleExtendsExceptionlooked like somewhat we already had to me, but maybe i overlooked the features of them.sobolevn commentedon Aug 12, 2021
This looks easier and more flexible to me right now.
I will show you the code soon 🙂
WIP: adds better exception macro, refs RustPython#2771
WIP: adds better exception macro, refs RustPython#2771
WIP: adds better exception macro, refs RustPython#2771