Fix bug that causes parameterized type annotations to lose their arguments. This prevents errors in Python 3.5 when combined with #40132.

PiperOrigin-RevId: 315961338
Change-Id: I01604b87bcee4b8e687055f727b8bdfc5da53376
This commit is contained in:
Dan Moldovan 2020-06-11 13:04:55 -07:00 committed by TensorFlower Gardener
parent 35bd7ea5b5
commit c3067cb521

View File

@ -152,7 +152,9 @@ def _get_wrapper(x, tf_should_use_helper):
return memoized(x, tf_should_use_helper)
tx = copy.deepcopy(type_x)
copy_tx = type(tx.__name__, tx.__bases__, dict(tx.__dict__))
# Prefer using __orig_bases__, which preserve generic type arguments.
bases = getattr(tx, '__orig_bases__', tx.__bases__)
copy_tx = type(tx.__name__, bases, dict(tx.__dict__))
copy_tx.__init__ = _new__init__
copy_tx.__getattribute__ = _new__getattribute__
copy_tx.mark_used = _new_mark_used