From 3d8fbb0716df669b552daef8ada02b4357ca7b49 Mon Sep 17 00:00:00 2001 From: kobarity Date: Wed, 6 Aug 2025 23:08:49 +0900 Subject: Fix Python PDB tracking for remote inferior Python * lisp/progmodes/python.el (python-shell-local-prefix): New constant. (python-shell--convert-file-name-to-send): New function to add/remove prefix. (python-shell-send-string, python-shell-send-file): Changed to use 'python-shell--convert-file-name-to-send'. (python-pdbtrack-set-tracked-buffer): Changed to add/remove prefix. * test/lisp/progmodes/python-tests.el (python-shell--convert-file-name-to-send-1): New test. (Bug#79036) --- test/lisp/progmodes/python-tests.el | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test/lisp/progmodes/python-tests.el') diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index d65ef39abb4..b9130da495d 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -4602,6 +4602,32 @@ and `python-shell-interpreter-args' in the new shell buffer." "^\\(o\\.t \\|\\)"))) (ignore-errors (delete-file startup-file)))))) +(ert-deftest python-shell--convert-file-name-to-send-1 () + "Test parameters consist of a list of the following three elements. +1. The variable `default-directory' of the process. +2. FILE-NAME argument. +3. The expected return value." + (python-tests-with-temp-buffer-with-shell + "" + (let* ((path "/tmp/tmp.py") + (local-path (concat python-shell-local-prefix path)) + (remote1-path (concat "/ssh:remote1:" path)) + (remote2-path (concat "/ssh:remote2:" path)) + (process (python-shell-get-process))) + (dolist + (test (list (list "/tmp" nil nil) + (list "/tmp" path path) + (list "/tmp" local-path path) + (list "/ssh:remote1:/tmp" path local-path) + (list "/ssh:remote1:/tmp" local-path local-path) + (list "/ssh:remote1:/tmp" remote1-path path) + (list "/ssh:remote1:/tmp" remote2-path remote2-path))) + (with-current-buffer (process-buffer process) + (setq default-directory (nth 0 test))) + (should (string= (python-shell--convert-file-name-to-send + process (nth 1 test)) + (nth 2 test))))))) + (ert-deftest python-shell-buffer-substring-1 () "Selecting a substring of the whole buffer must match its contents." (python-tests-with-temp-buffer -- cgit v1.2.1