Bug report
Bug description:
Objects like typing.List[int] allow arbitrary dunders to be set, and because of the cache, those attributes can leak to other objects created elsewhere in the program:
>>> x = List[int]
>>> x.__whatever__ = 42
>>> List[int].__whatever__
42
The cache behavior seems like it could lead to undesirable behavior. In 3.14 we somewhat accidentally fixed a similar bug with Union objects, and it turns out some people were relying on this: #132139. Let's think about whether we also want to remove this wart for other typing objects in 3.15.
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Bug report
Bug description:
Objects like
typing.List[int]allow arbitrary dunders to be set, and because of the cache, those attributes can leak to other objects created elsewhere in the program:The cache behavior seems like it could lead to undesirable behavior. In 3.14 we somewhat accidentally fixed a similar bug with Union objects, and it turns out some people were relying on this: #132139. Let's think about whether we also want to remove this wart for other typing objects in 3.15.
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response