Skip to content

Conversation

@sweeneyde
Copy link
Member

@sweeneyde sweeneyde commented Apr 18, 2022

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.
Copy link
Member

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?

Copy link
Member Author

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.

@pablogsal
Copy link
Member

Does this require backports?

@sweeneyde
Copy link
Member Author

sweeneyde commented Apr 21, 2022

3.10 and 3.9 have no &_Py_STR(empty)), so I don't think backporting is very straightforward. This is a contrived edge-case, so maybe it's best to only touch 3.11?

@sweeneyde sweeneyde merged commit f2b4e45 into python:main Apr 21, 2022
@sweeneyde sweeneyde deleted the func_clear branch April 21, 2022 06:06
@sweeneyde sweeneyde mentioned this pull request Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants