-
Notifications
You must be signed in to change notification settings - Fork 776
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
Enable recursive classattribute #982
Comments
I’ll take this one. |
Thanks, I assigned you. |
So I did a bit of archeology. As @davidhewitt noted, the tp_dict documentation features contradictory information about modifying the A On the latter issue, it is explained that adding attributes to the In #1878, it's explained that one can disable this interaction with the method cache by unsetting the After reading the implementation, I believe that there is another method: PyType_Modified invalidates the method cache, and according to the documentation, its purpose is exactly that of modifying class attributes through the We have an example in cpython where the The implementation doesn't bother with In our case, we're going to fill the I have a working implementation which I'll post on monday (I wrote the code at work and don't have access to it right now). |
Thanks for the the really thorough investigation here!
Can't recursive class attributes potentially do things like create objects of the type and call methods on them? I might be tempted to call |
Wow, thank you for the detailed survey! Though I still don't understand the context completely, it looks that we don't have to use I addition, thanks to ripgrep, I found another instance where
|
Ah sorry, this is wrong.
How about calling the user code before calling |
Yes, that’s my thought too.
I guess this is the same reasoning as with the
I think we agreed that it was potentially unsound to start using the type object from user code before |
Ah, sorry, I actually forgot that we're tackling the 'recursive' case 😓 Then I think |
Closed via #995 |
We can use
Self
as a classattribute, like this:.
However, by #975, this is temporally prohibited due to a soundness problem, and thus this code panics.
We should be able to enable this by changing the strategy for initializing
tp_dict
as suggested by @scalexm in the comment.The text was updated successfully, but these errors were encountered: