Skip to content

Commit 82f6654

Browse files
alvarosgcopybara-github
authored andcommitted
Fix fiddle serialization bug that affects class methods referenced from child classes.
Also adding corresponding test. PiperOrigin-RevId: 864314179
1 parent 3d956df commit 82f6654

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

fiddle/_src/experimental/serialization.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,13 @@ def _pyref(self, value, current_path: daglish.Path):
583583
module_name = module.__name__
584584
if isinstance(value, enum.Enum):
585585
symbol = value.__class__.__qualname__ + '.' + value.name
586+
elif isinstance(value, types.MethodType) and hasattr(
587+
value.__self__, '__qualname__'
588+
):
589+
# Class methods needs special handling, since `value.__qualname__` returns
590+
# the wrong class (the parent) when a class method that is defined in
591+
# parent classes, is referenced from the child class.
592+
symbol = value.__self__.__qualname__ + '.' + value.__name__
586593
else:
587594
symbol = value.__qualname__
588595
# Check to make sure we can import the symbol.

0 commit comments

Comments
 (0)