mirror of
https://github.com/python/cpython.git
synced 2025-10-02 21:25:24 +00:00
[3.12] gh-115165: Fix typing.Annotated
for immutable types (GH-115213) (#115227)
gh-115165: Fix `typing.Annotated` for immutable types (GH-115213)
The return value from an annotated callable can raise any exception from
__setattr__ for the `__orig_class__` property.
(cherry picked from commit 564385612c
)
Co-authored-by: dave-shawley <daveshawley@gmail.com>
This commit is contained in:
parent
3539b02873
commit
321ec5e0fe
3 changed files with 28 additions and 1 deletions
|
@ -1140,7 +1140,9 @@ class _BaseGenericAlias(_Final, _root=True):
|
|||
result = self.__origin__(*args, **kwargs)
|
||||
try:
|
||||
result.__orig_class__ = self
|
||||
except AttributeError:
|
||||
# Some objects raise TypeError (or something even more exotic)
|
||||
# if you try to set attributes on them; we guard against that here
|
||||
except Exception:
|
||||
pass
|
||||
return result
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue