Fix weakref unwrapping in AutoGraph conversion
PiperOrigin-RevId: 225850437
This commit is contained in:
parent
a1c66b9f15
commit
d914628367
@ -218,6 +218,11 @@ class ConversionOptions(object):
|
||||
def as_qualified_name(o):
|
||||
name = inspect_utils.getqualifiedname(ctx.info.namespace, o, max_depth=1)
|
||||
if not name:
|
||||
if isinstance(o, weakref.ref):
|
||||
# `o` might already be a weak reference, if this object was
|
||||
# constructed from code generated by `to_ast` itself.
|
||||
# If so, unpack it.
|
||||
o = o()
|
||||
# TODO(mdan): This needs to account for the symbols defined locally.
|
||||
name = ctx.namer.new_symbol(o.__name__, ())
|
||||
ctx.program.add_symbol(name, weakref.ref(o))
|
||||
|
Loading…
Reference in New Issue
Block a user