aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorChong Yidong2010-11-27 15:04:57 -0500
committerChong Yidong2010-11-27 15:04:57 -0500
commit07976ae3b816dea4fd541bbba862603d3132eb2c (patch)
tree4a437b7cb3abb01fb144530a130c991882a1b7f2 /lisp/progmodes/python.el
parent9610796712a3bc43730c99005906571a2c0bccbd (diff)
parent402c8a49571227f8a4e678d4a6cdd6ba7841aef9 (diff)
downloademacs-07976ae3b816dea4fd541bbba862603d3132eb2c.tar.gz
emacs-07976ae3b816dea4fd541bbba862603d3132eb2c.zip
Merge changes from emacs-23 branch
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el52
1 files changed, 31 insertions, 21 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 9fe57beec30..0a641d0945f 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1462,6 +1462,16 @@ Default ignores all inputs of 0, 1, or 2 non-blank characters."
1462 :type 'regexp 1462 :type 'regexp
1463 :group 'python) 1463 :group 'python)
1464 1464
1465(defcustom python-remove-cwd-from-path t
1466 "Whether to allow loading of Python modules from the current directory.
1467If this is non-nil, Emacs removes '' from sys.path when starting
1468an inferior Python process. This is the default, for security
1469reasons, as it is easy for the Python process to be started
1470without the user's realization (e.g. to perform completion)."
1471 :type 'boolean
1472 :group 'python
1473 :version "23.3")
1474
1465(defun python-input-filter (str) 1475(defun python-input-filter (str)
1466 "`comint-input-filter' function for inferior Python. 1476 "`comint-input-filter' function for inferior Python.
1467Don't save anything for STR matching `inferior-python-filter-regexp'." 1477Don't save anything for STR matching `inferior-python-filter-regexp'."
@@ -1559,20 +1569,24 @@ print version_info >= (2, 2) and version_info < (3, 0)\""))))
1559;;;###autoload 1569;;;###autoload
1560(defun run-python (&optional cmd noshow new) 1570(defun run-python (&optional cmd noshow new)
1561 "Run an inferior Python process, input and output via buffer *Python*. 1571 "Run an inferior Python process, input and output via buffer *Python*.
1562CMD is the Python command to run. NOSHOW non-nil means don't show the 1572CMD is the Python command to run. NOSHOW non-nil means don't
1563buffer automatically. 1573show the buffer automatically.
1564 1574
1565Normally, if there is a process already running in `python-buffer', 1575Interactively, a prefix arg means to prompt for the initial
1566switch to that buffer. Interactively, a prefix arg allows you to edit 1576Python command line (default is `python-command').
1567the initial command line (default is `python-command'); `-i' etc. args 1577
1568will be added to this as appropriate. A new process is started if: 1578A new process is started if one isn't running attached to
1569one isn't running attached to `python-buffer', or interactively the 1579`python-buffer', or if called from Lisp with non-nil arg NEW.
1570default `python-command', or argument NEW is non-nil. See also the 1580Otherwise, if a process is already running in `python-buffer',
1571documentation for `python-buffer'. 1581switch to that buffer.
1572 1582
1573Runs the hook `inferior-python-mode-hook' \(after the 1583This command runs the hook `inferior-python-mode-hook' after
1574`comint-mode-hook' is run). \(Type \\[describe-mode] in the process 1584running `comint-mode-hook'. Type \\[describe-mode] in the
1575buffer for a list of commands.)" 1585process buffer for a list of commands.
1586
1587By default, Emacs inhibits the loading of Python modules from the
1588current working directory, for security reasons. To disable this
1589behavior, change `python-remove-cwd-from-path' to nil."
1576 (interactive (if current-prefix-arg 1590 (interactive (if current-prefix-arg
1577 (list (read-string "Run Python: " python-command) nil t) 1591 (list (read-string "Run Python: " python-command) nil t)
1578 (list python-command))) 1592 (list python-command)))
@@ -1586,13 +1600,9 @@ buffer for a list of commands.)"
1586 (when (or new (not (comint-check-proc python-buffer))) 1600 (when (or new (not (comint-check-proc python-buffer)))
1587 (with-current-buffer 1601 (with-current-buffer
1588 (let* ((cmdlist 1602 (let* ((cmdlist
1589 (append (python-args-to-list cmd) 1603 (append (python-args-to-list cmd) '("-i")
1590 ;; It's easy for the user to cause the process to be 1604 (if python-remove-cwd-from-path
1591 ;; started without realizing it (e.g. to perform 1605 '("-c" "import sys; sys.path.remove('')"))))
1592 ;; completion); for this reason loading files from the
1593 ;; current directory is a security risk. See
1594 ;; http://article.gmane.org/gmane.emacs.devel/103569
1595 '("-i" "-c" "import sys; sys.path.remove('')")))
1596 (path (getenv "PYTHONPATH")) 1606 (path (getenv "PYTHONPATH"))
1597 (process-environment ; to import emacs.py 1607 (process-environment ; to import emacs.py
1598 (cons (concat "PYTHONPATH=" 1608 (cons (concat "PYTHONPATH="