Subject: bug#41619: [PATCH] Mark python-shell-virtualenv-root as safe local variable

From: "Philip K." <[email-masked]>
Date: Sat, 30 May 2020 22:31:09 +0200

Hi,

I was trying to work with python today and it required me to use a
virtual environment. I noticed that python-mode already had some basic
virtualenv facilites, and it all worked. The only thing that annoyed me
was that I couldn't configure the setup to be properly persistent, since
python-shell-virtualenv-root couldn't be set as a directory local
variable.

The commentary section mentions

> ;; (setq python-shell-virtualenv-root "/path/to/env/")

but I couldn't find any other details on how the mode expects me to set
the variable.

Therefore I patched the few lines, and it works great.

>From 31beb4931ae7800e719ac470ba8bd14a977f765c Mon Sep 17 00:00:00 2001
From: Philip K <[email-masked]>
Date: Sat, 30 May 2020 21:47:51 +0200
Subject: [PATCH] Mark python-shell-virtualenv-root as safe for directories

---
 lisp/progmodes/python.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 1ca9f01963..f9537b4079 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -2090,7 +2090,8 @@ python-shell-virtualenv-root
 This variable, when set to a string, makes the environment to be
 modified such that shells are started within the specified
 virtualenv."
-  :type '(choice (const nil) string)
+  :type '(choice (const nil) directory)
+  :safe #'file-directory-p
   :group 'python)
 
 (defcustom python-shell-setup-codes nil
-- 
2.26.2