aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el48
1 files changed, 31 insertions, 17 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 5d528e5fa28..653ef3150e5 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1426,6 +1426,16 @@ Default ignores all inputs of 0, 1, or 2 non-blank characters."
1426 :type 'regexp 1426 :type 'regexp
1427 :group 'python) 1427 :group 'python)
1428 1428
1429(defcustom python-remove-cwd-from-path t
1430 "Whether to allow loading of Python modules from the current directory.
1431If this is non-nil, Emacs removes '' from sys.path when starting
1432an inferior Python process. This is the default, for security
1433reasons, as it is easy for the Python process to be started
1434without the user's realization (e.g. to perform completion)."
1435 :type 'boolean
1436 :group 'python
1437 :version "23.3")
1438
1429(defun python-input-filter (str) 1439(defun python-input-filter (str)
1430 "`comint-input-filter' function for inferior Python. 1440 "`comint-input-filter' function for inferior Python.
1431Don't save anything for STR matching `inferior-python-filter-regexp'." 1441Don't save anything for STR matching `inferior-python-filter-regexp'."
@@ -1523,20 +1533,24 @@ Don't save anything for STR matching `inferior-python-filter-regexp'."
1523;;;###autoload 1533;;;###autoload
1524(defun run-python (&optional cmd noshow new) 1534(defun run-python (&optional cmd noshow new)
1525 "Run an inferior Python process, input and output via buffer *Python*. 1535 "Run an inferior Python process, input and output via buffer *Python*.
1526CMD is the Python command to run. NOSHOW non-nil means don't show the 1536CMD is the Python command to run. NOSHOW non-nil means don't
1527buffer automatically. 1537show the buffer automatically.
1528 1538
1529Normally, if there is a process already running in `python-buffer', 1539Interactively, a prefix arg means to prompt for the initial
1530switch to that buffer. Interactively, a prefix arg allows you to edit 1540Python command line (default is `python-command').
1531the initial command line (default is `python-command'); `-i' etc. args 1541
1532will be added to this as appropriate. A new process is started if: 1542A new process is started if one isn't running attached to
1533one isn't running attached to `python-buffer', or interactively the 1543`python-buffer', or if called from Lisp with non-nil arg NEW.
1534default `python-command', or argument NEW is non-nil. See also the 1544Otherwise, if a process is already running in `python-buffer',
1535documentation for `python-buffer'. 1545switch to that buffer.
1536 1546
1537Runs the hook `inferior-python-mode-hook' \(after the 1547This command runs the hook `inferior-python-mode-hook' after
1538`comint-mode-hook' is run). \(Type \\[describe-mode] in the process 1548running `comint-mode-hook'. Type \\[describe-mode] in the
1539buffer for a list of commands.)" 1549process buffer for a list of commands.
1550
1551By default, Emacs inhibits the loading of Python modules from the
1552current working directory, for security reasons. To disable this
1553behavior, change `python-remove-cwd-from-path' to nil."
1540 (interactive (if current-prefix-arg 1554 (interactive (if current-prefix-arg
1541 (list (read-string "Run Python: " python-command) nil t) 1555 (list (read-string "Run Python: " python-command) nil t)
1542 (list python-command))) 1556 (list python-command)))
@@ -1549,9 +1563,9 @@ buffer for a list of commands.)"
1549 (when (or new (not (comint-check-proc python-buffer))) 1563 (when (or new (not (comint-check-proc python-buffer)))
1550 (with-current-buffer 1564 (with-current-buffer
1551 (let* ((cmdlist 1565 (let* ((cmdlist
1552 (append (python-args-to-list cmd) 1566 (append (python-args-to-list cmd) '("-i")
1553 ;; See http://lists.gnu.org/archive/html/emacs-devel/2008-09/msg00215.html 1567 (if python-remove-cwd-from-path
1554 '("-i" "-c" "import sys; sys.path.remove('')"))) 1568 '("-c" "import sys; sys.path.remove('')"))))
1555 (path (getenv "PYTHONPATH")) 1569 (path (getenv "PYTHONPATH"))
1556 (process-environment ; to import emacs.py 1570 (process-environment ; to import emacs.py
1557 (cons (concat "PYTHONPATH=" 1571 (cons (concat "PYTHONPATH="