From 031be42a8b3efa8a148a37ae4f2ed74040403bda Mon Sep 17 00:00:00 2001 From: Philip Nuzhnyi Date: Fri, 13 Dec 2024 09:02:47 +0000 Subject: [PATCH] gracefully handle explicit transient=None re #321 --- nbclient/client.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nbclient/client.py b/nbclient/client.py index 40f4c62..2f83708 100644 --- a/nbclient/client.py +++ b/nbclient/client.py @@ -1100,7 +1100,12 @@ def process_message( content = msg["content"] self.log.debug("content: %s", content) - display_id = content.get("transient", {}).get("display_id", None) + # while it's tempting to go for a more concise + # display_id = content.get("transient", {}).get("display_id", None) + # this breaks if transient is explicitly set to None + transient = content.get("transient", {}) + display_id = transient.get("display_id", None) if transient else None + if display_id and msg_type in {"execute_result", "display_data", "update_display_data"}: self._update_display_id(display_id, msg)