From 8d56e681465b035a7194cb97988555d701a69455 Mon Sep 17 00:00:00 2001 From: Louis Mandel Date: Mon, 17 Nov 2025 11:22:58 -0500 Subject: [PATCH] fix: stringify as json when contributing to a string Signed-off-by: Louis Mandel --- src/pdl/pdl_interpreter.py | 7 ++++++- src/pdl/pdl_utils.py | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pdl/pdl_interpreter.py b/src/pdl/pdl_interpreter.py index d88b23514..6b40843e6 100644 --- a/src/pdl/pdl_interpreter.py +++ b/src/pdl/pdl_interpreter.py @@ -2509,7 +2509,12 @@ def contribute( loc: Optional[PdlLocationType] = None, block: Optional[BlockType] = None, ) -> "FileAggregator": - print(f"{self.prefix}{result}", file=self.fp, end=self.suffix, flush=self.flush) + print( + f"{self.prefix}{stringify(result)}", + file=self.fp, + end=self.suffix, + flush=self.flush, + ) return self diff --git a/src/pdl/pdl_utils.py b/src/pdl/pdl_utils.py index 6332950f7..1694ee82d 100644 --- a/src/pdl/pdl_utils.py +++ b/src/pdl/pdl_utils.py @@ -15,6 +15,7 @@ get_sampling_defaults, ) from .pdl_dumper import as_json, block_to_dict +from .pdl_lazy import PdlLazy RefT = TypeVar("RefT") @@ -64,6 +65,8 @@ async def to_async(value: ToAsyncT) -> ToAsyncT: def stringify(result): + if isinstance(result, PdlLazy): + result = result.result() if isinstance(result, str): s = result elif isinstance(result, FunctionBlock):