-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Properly handles del val.__dict__.
#5576
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
2010890
1abd204
c43327e
79d70e3
02ce85a
425fd4f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Co-authored-by: Jeong, YunWon <69878+youknowone@users.noreply.github.com>
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -713,7 +713,7 @@ impl PyObject { | |
| /// Set the dict field. Returns `Err(dict)` if this object does not have a dict field | ||
| /// in the first place. | ||
| pub fn set_dict(&self, dict: PySetterValue<PyDictRef>) -> Option<()> { | ||
| // NOTE(hanif) - So far, this is the only error condition that I know of so we can use Option | ||
| // NOTE: So far, this is the only error condition that I know of so we can use Option | ||
| // for now. | ||
| if self.payload_is::<crate::builtins::function::PyFunction>() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am sorry. I don't get how
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because deleting dict of a function is not allowed. class A:
pass
def ff():
return 0
# Deleting __dict__ of class is fine
a = A()
print(a.__dict__)
del a.__dict__
# Deleting __dict__ of function is not allowed
print(ff.__dict__)
del ff.__dict__Yields Perhaps I should have added comments.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of PyFunction, isn't it a similar, but different rule? e.g. static types, immutable types etc
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe |
||
| return None; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The doc-comment doesn't fit in actual implementation anymore