From 031be42a8b3efa8a148a37ae4f2ed74040403bda Mon Sep 17 00:00:00 2001 From: Philip Nuzhnyi Date: Fri, 13 Dec 2024 09:02:47 +0000 Subject: [PATCH 1/2] 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) From 36251312df7fbe02f1ae5a3089e3319302b43fd9 Mon Sep 17 00:00:00 2001 From: Philip Nuzhnyi Date: Thu, 19 Dec 2024 08:35:24 +0000 Subject: [PATCH 2/2] rephrase --- nbclient/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nbclient/client.py b/nbclient/client.py index 2f83708..936bb4a 100644 --- a/nbclient/client.py +++ b/nbclient/client.py @@ -1103,8 +1103,8 @@ def process_message( # 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 + transient = content.get("transient") + display_id = transient.get("display_id") 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)