diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 227be64b5b0..a50446343a0 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -3030,11 +3030,11 @@ machine then modifies `tramp-remote-process-environment' and (tramp-dissect-file-name default-directory 'noexpand))))) (if vec (python-shell--tramp-with-environment vec extraenv bodyfun) - (let ((process-environment - (append extraenv process-environment)) - (exec-path - ;; FIXME: This is still Python-specific. - (python-shell-calculate-exec-path))) + (cl-letf (((default-value 'process-environment) + (append extraenv process-environment)) + ((default-value 'exec-path) + ;; FIXME: This is still Python-specific. + (python-shell-calculate-exec-path))) (funcall bodyfun))))) (defun python-shell--tramp-with-environment (vec extraenv bodyfun)