-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-91636: Don't clear required fields of function objects #91651
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
Conversation
Objects/funcobject.c
Outdated
Py_CLEAR(op->func_module); | ||
Py_CLEAR(op->func_defaults); | ||
Py_CLEAR(op->func_kwdefaults); | ||
Py_CLEAR(op->func_doc); | ||
Py_CLEAR(op->func_dict); | ||
Py_CLEAR(op->func_closure); | ||
Py_CLEAR(op->func_annotations); | ||
/* Below are required attributes, so to keep everything in | ||
* a consistent state, don't clear them. They're immutable, | ||
* so they can't participate in cycles anyway. |
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.
Did you confirm that Unicode subclass are not allowed?
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.
Ah, good catch, it can be a subclass:
>>> def f():
... pass
...
>>> class S(str):
... pass
...
>>> f.__name__ = S("???") # no error
I don't know what a good solution is.
Does this require backports? |
3.10 and 3.9 have no |
#91636