◐ Shell
clean mode source ↗

gh-104600: Make function.__type_params__ writable by JelleZijlstra · Pull Request #104601 · python/cpython

Conversation

carljm

Eclips4

{
/* Not legal to del f.__type_params__ or to set it to anything
* other than a tuple object. */
if (value == NULL || !PyTuple_Check(value)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to use PyTuple_CheckExact instead of PyTuple_Check? With PyTuple_Check we can pass to __type_params__ subclass of tuple. May it break something?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't really use the __type_params__ in the interpreter, so there's low risk. The other attributes also allow subclasses (e.g. check func_set_defaults and func_set_name).