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
Some failures in whats_left.sh: method inheritance not as expected #2732
The whats_left.sh script generates a list of incompatibilities by comparing signatures with inspect.signature(). I think one source of mismatches is because of how builtin object inherit (or don't inherit) from object. I don't yet understand how RustPython is doing this so I'm documenting the issue here, but I could write a PR with some help.
Description
As an example: sys.__loader__ is listed by whats_left because signature() returns a ValueError. The CPython signature is (), which is the default signature of object.
In both CPython and RustPython inspect.signature is calling inspect._signature_from_callable() (code), which eventually gets to this block.
The class is an instance of _frozen_importlib.BuiltinImporter which has no __init__ or __new__ method defined. In CPython, both of those methods are the same as the object methods (using the is test, e.g. the same memory address). In RustPython the __new__ method is different. I would guess that something about the class definition is creating a separate __new__ method even though there shouldn't be one.
Unfortunately no, I just collapse the error into a single message.
In the case of __loader__ the same message showed up many times because every built-in module had a __loader__ instance that came from _frozen_importlib. So my PRs turn that into one message but the underlying cause is still there.
I resolved #2869 so I believe this issue is also resolved as I understood. To prove this issue is resolved, I executed ./whats_left.sh and looked up sys.__loader__ but I couldn't. But I can't feel sure that this issue was resolved, could you check it? @jamestwebber
Yes, this is fixed! The messages were no longer output by whats_left because in #2760 I tweaked the code to remove items defined in other modules (in retrospect perhaps this was too broad, as there are no examples of __loader__ left to check). But I verified the change in behavior which fixes this issue:
>>>>>importsys>>>>>sys.__loader__.__init__isobject.__init__True>>>>>sys.__loader__.__new__isobject.__new__True# was previously False
This has uncovered a new issue: in CPython, inspect.signature(object) will return () but RustPython raises a ValueError. I think this is a different problem though.
Activity
youknowone commentedon Aug 4, 2021
@jamestwebber is this fixed by your PRs?
jamestwebber commentedon Aug 4, 2021
Unfortunately no, I just collapse the error into a single message.
In the case of
__loader__the same message showed up many times because every built-in module had a__loader__instance that came from_frozen_importlib. So my PRs turn that into one message but the underlying cause is still there.moreal commentedon Aug 14, 2021
I resolved #2869 so I believe this issue is also resolved as I understood. To prove this issue is resolved, I executed
./whats_left.shand looked upsys.__loader__but I couldn't. But I can't feel sure that this issue was resolved, could you check it? @jamestwebberjamestwebber commentedon Aug 14, 2021
Yes, this is fixed! The messages were no longer output by
whats_leftbecause in #2760 I tweaked the code to remove items defined in other modules (in retrospect perhaps this was too broad, as there are no examples of__loader__left to check). But I verified the change in behavior which fixes this issue:This has uncovered a new issue: in CPython,
inspect.signature(object)will return()but RustPython raises a ValueError. I think this is a different problem though.jamestwebber commentedon Aug 14, 2021
Oh, the underlying issue is now #2410 which you're already working on 🎉