diff options
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 52 |
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. | ||
| 1467 | If this is non-nil, Emacs removes '' from sys.path when starting | ||
| 1468 | an inferior Python process. This is the default, for security | ||
| 1469 | reasons, as it is easy for the Python process to be started | ||
| 1470 | without 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. |
| 1467 | Don't save anything for STR matching `inferior-python-filter-regexp'." | 1477 | Don'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*. |
| 1562 | CMD is the Python command to run. NOSHOW non-nil means don't show the | 1572 | CMD is the Python command to run. NOSHOW non-nil means don't |
| 1563 | buffer automatically. | 1573 | show the buffer automatically. |
| 1564 | 1574 | ||
| 1565 | Normally, if there is a process already running in `python-buffer', | 1575 | Interactively, a prefix arg means to prompt for the initial |
| 1566 | switch to that buffer. Interactively, a prefix arg allows you to edit | 1576 | Python command line (default is `python-command'). |
| 1567 | the initial command line (default is `python-command'); `-i' etc. args | 1577 | |
| 1568 | will be added to this as appropriate. A new process is started if: | 1578 | A new process is started if one isn't running attached to |
| 1569 | one isn't running attached to `python-buffer', or interactively the | 1579 | `python-buffer', or if called from Lisp with non-nil arg NEW. |
| 1570 | default `python-command', or argument NEW is non-nil. See also the | 1580 | Otherwise, if a process is already running in `python-buffer', |
| 1571 | documentation for `python-buffer'. | 1581 | switch to that buffer. |
| 1572 | 1582 | ||
| 1573 | Runs the hook `inferior-python-mode-hook' \(after the | 1583 | This command runs the hook `inferior-python-mode-hook' after |
| 1574 | `comint-mode-hook' is run). \(Type \\[describe-mode] in the process | 1584 | running `comint-mode-hook'. Type \\[describe-mode] in the |
| 1575 | buffer for a list of commands.)" | 1585 | process buffer for a list of commands. |
| 1586 | |||
| 1587 | By default, Emacs inhibits the loading of Python modules from the | ||
| 1588 | current working directory, for security reasons. To disable this | ||
| 1589 | behavior, 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=" |