Support del __dict__#5378
Conversation
There was a problem hiding this comment.
This is the correct directory. Putting this test under builtin_object.py is also fine.
|
The change looks good, but function type seems not allowing to do it. The related type is Adding a getset is possible like: // This impl must be one of `#[pyclass]` annotated
impl PyFunction {
#[pygetset(setter)]
fn __dict__(zelf: &Py<Self>, value: dict: PySetterValue<PyDictRef>,, vm: &VirtualMachine) -> ...
} |
|
I found out, how to delegate the
I guess this happens, because Should i add these three to the |
|
Thank you for analysis. That's a good point. Yes, making them as its own getset totally makes sense. And yes, in separated PR would be better. |
|
I was able to remove I declared them like this #[pygetset(magic)]
fn doc(&self) -> PyObjectRef {...}
#[pygetset(magic, setter)]
fn set_doc(&self, value: PyObjectRef) {...}So, something is intercepting the calls to my pygetset. Any idea what that might be? I looked at other pygetset for It also does not matter whether the function actually has a doc-string. If i comment out the part in |
|
@nielsbuwen Making a PR of that changes will be helpful for me to understand what's happening. My first guess is |
|
@youknowone here you go: #5392 |
I would like to take over this good first issue: #5355
It brings the interpreter in line with the cpython behaviour when deleting
__dict__attributes.Basically this replaces the instance dict with an empty dictionary. This seems to duplicate the cpython behaviour.
Things to improve
I don't like the(found it)let new_dict = match dictwhere i take the given dict or and empty one. I could add aunwrap_or_defaultfor thePySetterValue?I also don't like the(i guess i found it)let value = match value {where i convert theAssignfrom aPyObjectRefinto aPyDictRef. But i could not find amap*variant that let's me pass a function that returns a PyResultI'd love to hear your suggestions