From 59989a3b97a278da5bd1e6d645147ba8278aef86 Mon Sep 17 00:00:00 2001 From: Isabel Zimmerman <54685329+isabelizimm@users.noreply.github.com> Date: Fri, 19 Apr 2024 09:35:38 -0400 Subject: [PATCH] Update extensions/positron-python/python_files/positron/positron_ipykernel/positron_ipkernel.py Co-authored-by: Wasim Lorgat Signed-off-by: Isabel Zimmerman <54685329+isabelizimm@users.noreply.github.com> --- .../positron/positron_ipykernel/positron_ipkernel.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/extensions/positron-python/python_files/positron/positron_ipykernel/positron_ipkernel.py b/extensions/positron-python/python_files/positron/positron_ipykernel/positron_ipkernel.py index 6a09a76898d..4dba3b1f01e 100644 --- a/extensions/positron-python/python_files/positron/positron_ipykernel/positron_ipkernel.py +++ b/extensions/positron-python/python_files/positron/positron_ipykernel/positron_ipkernel.py @@ -534,12 +534,16 @@ def _showwarning(message, category, filename, lineno, file=None, line=None): # if coming from one of our files, log and don't send to user positron_files_path = Path("python_files", "positron", "positron_ipykernel") - console_dir = get_tmp_directory() if str(positron_files_path) in str(filename): msg = f"{category}: {message}" logger.warning(msg) return + # Check if the filename refers to a cell in the Positron Console. + # We use the fact that ipykernel sets the filename to a path starting in the root temporary + # directory. We can't determine the full filename since it depends on the cell's code which + # is unknown at this point. See ipykernel.compiler.XCachingCompiler.get_code_name. + console_dir = get_tmp_directory() if console_dir in str(filename): filename = "POSITRON_CONSOLE"