From f9c517e868462d05d6854204c2ad0a244db1cd19 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 27 Nov 2023 12:21:00 -0600 Subject: [PATCH] Fix edit magic payload type (#1171) --- ipykernel/zmqshell.py | 2 +- tests/test_zmq_shell.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ipykernel/zmqshell.py b/ipykernel/zmqshell.py index 21983b50..4f7e2f5a 100644 --- a/ipykernel/zmqshell.py +++ b/ipykernel/zmqshell.py @@ -302,7 +302,7 @@ def edit(self, parameter_s="", last_call=None): # Make sure we send to the client an absolute path, in case the working # directory of client and kernel don't match - filename = Path(filename).resolve() + filename = str(Path(filename).resolve()) payload = {"source": "edit_magic", "filename": filename, "line_number": lineno} assert self.shell is not None diff --git a/tests/test_zmq_shell.py b/tests/test_zmq_shell.py index 57a70f30..dfd22dec 100644 --- a/tests/test_zmq_shell.py +++ b/tests/test_zmq_shell.py @@ -220,6 +220,9 @@ def test_magics(tmp_path): tmp_file = tmp_path / "test.txt" tmp_file.write_text("hi", "utf8") magics.edit(str(tmp_file)) + payload = shell.payload_manager.read_payload()[0] + assert payload["filename"] == str(tmp_file) + magics.clear([]) magics.less(str(tmp_file)) if os.name == "posix":