Fix tf_convert on decorated methods, again
The original fix was incorrect. tf_convert() should continue to return the bound method, instead of the underlying function. PiperOrigin-RevId: 334471644 Change-Id: Ic48ce06e54dd9240144bf946aa5a987a87078de5
This commit is contained in:
parent
a33e1875e3
commit
8c7d50fcfd
@ -297,8 +297,9 @@ def _convert_actual(entity, program_ctx):
|
||||
|
||||
def autograph_artifact(entity, extras=None):
|
||||
if inspect.ismethod(entity):
|
||||
entity = entity.__func__
|
||||
setattr(entity, 'autograph_info__', extras)
|
||||
setattr(entity.__func__, 'autograph_info__', extras)
|
||||
else:
|
||||
setattr(entity, 'autograph_info__', extras)
|
||||
return entity
|
||||
|
||||
|
||||
|
@ -1213,8 +1213,9 @@ class ApiTest(test.TestCase):
|
||||
obj = TestClass()
|
||||
# It's intended that tf_convert modifies the original method in this case.
|
||||
# This is not desirable, but options are limited.
|
||||
api.tf_convert(obj.method,
|
||||
ag_ctx.ControlStatusCtx(status=ag_ctx.Status.ENABLED))
|
||||
converted = api.tf_convert(
|
||||
obj.method, ag_ctx.ControlStatusCtx(status=ag_ctx.Status.ENABLED))
|
||||
self.assertTrue(converted())
|
||||
self.assertTrue(obj.method())
|
||||
|
||||
def test_super_with_one_arg(self):
|
||||
|
Loading…
Reference in New Issue
Block a user