emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/emacs-23 r100227: Make the sys.path remove


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/emacs-23 r100227: Make the sys.path remove in Python mode customizable (Bug#7454).
Date: Sun, 21 Nov 2010 11:52:05 -0500
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 100227
committer: Chong Yidong <address@hidden>
branch nick: emacs-23
timestamp: Sun 2010-11-21 11:52:05 -0500
message:
  Make the sys.path remove in Python mode customizable (Bug#7454).
  * progmodes/python.el (run-python): Doc fix.
  (python-keep-current-directory-in-path): New var (Bug#7454).
modified:
  etc/NEWS
  lisp/ChangeLog
  lisp/progmodes/python.el
=== modified file 'etc/NEWS'
--- a/etc/NEWS  2010-11-20 23:16:10 +0000
+++ b/etc/NEWS  2010-11-21 16:52:05 +0000
@@ -36,6 +36,10 @@
 ** The appt-add command takes an optional argument for the warning time.
 This can be used in place of the default appt-message-warning-time.
 
+---
+** You can allow inferior Python processes to load modules from the
+current directory by setting `python-remove-cwd-from-path' to nil.
+
 ** VC and related modes
 
 *** New VC command `vc-log-incoming', bound to `C-x v I'.

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-11-20 20:23:26 +0000
+++ b/lisp/ChangeLog    2010-11-21 16:52:05 +0000
@@ -1,3 +1,8 @@
+2010-11-21  Chong Yidong  <address@hidden>
+
+       * progmodes/python.el (run-python): Doc fix.
+       (python-keep-current-directory-in-path): New var (Bug#7454).
+
 2010-11-20  Chong Yidong  <address@hidden>
 
        * lpr.el (lpr-buffer, print-buffer, lpr-region, print-region):

=== modified file 'lisp/progmodes/python.el'
--- a/lisp/progmodes/python.el  2010-11-21 02:19:39 +0000
+++ b/lisp/progmodes/python.el  2010-11-21 16:52:05 +0000
@@ -1426,6 +1426,16 @@
   :type 'regexp
   :group 'python)
 
+(defcustom python-remove-cwd-from-path t
+  "Whether to allow loading of Python modules from the current directory.
+If this is non-nil, Emacs removes '' from sys.path when starting
+an inferior Python process.  This is the default, for security
+reasons, as it is easy for the Python process to be started
+without the user's realization (e.g. to perform completion)."
+  :type 'boolean
+  :group 'python
+  :version "23.3")
+
 (defun python-input-filter (str)
   "`comint-input-filter' function for inferior Python.
 Don't save anything for STR matching `inferior-python-filter-regexp'."
@@ -1523,20 +1533,24 @@
 ;;;###autoload
 (defun run-python (&optional cmd noshow new)
   "Run an inferior Python process, input and output via buffer *Python*.
-CMD is the Python command to run.  NOSHOW non-nil means don't show the
-buffer automatically.
-
-Normally, if there is a process already running in `python-buffer',
-switch to that buffer.  Interactively, a prefix arg allows you to edit
-the initial command line (default is `python-command'); `-i' etc. args
-will be added to this as appropriate.  A new process is started if:
-one isn't running attached to `python-buffer', or interactively the
-default `python-command', or argument NEW is non-nil.  See also the
-documentation for `python-buffer'.
-
-Runs the hook `inferior-python-mode-hook' \(after the
-`comint-mode-hook' is run).  \(Type \\[describe-mode] in the process
-buffer for a list of commands.)"
+CMD is the Python command to run.  NOSHOW non-nil means don't
+show the buffer automatically.
+
+Interactively, a prefix arg means to prompt for the initial
+Python command line (default is `python-command').
+
+A new process is started if one isn't running attached to
+`python-buffer', or if called from Lisp with non-nil arg NEW.
+Otherwise, if a process is already running in `python-buffer',
+switch to that buffer.
+
+This command runs the hook `inferior-python-mode-hook' after
+running `comint-mode-hook'.  Type \\[describe-mode] in the
+process buffer for a list of commands.
+
+By default, Emacs inhibits the loading of Python modules from the
+current working directory, for security reasons.  To disable this
+behavior, change `python-remove-cwd-from-path' to nil."
   (interactive (if current-prefix-arg
                   (list (read-string "Run Python: " python-command) nil t)
                 (list python-command)))
@@ -1549,9 +1563,9 @@
   (when (or new (not (comint-check-proc python-buffer)))
     (with-current-buffer
        (let* ((cmdlist
-               (append (python-args-to-list cmd)
-                        ;; See 
http://lists.gnu.org/archive/html/emacs-devel/2008-09/msg00215.html
-                       '("-i" "-c" "import sys; sys.path.remove('')")))
+               (append (python-args-to-list cmd) '("-i")
+                       (if python-remove-cwd-from-path
+                           '("-c" "import sys; sys.path.remove('')"))))
               (path (getenv "PYTHONPATH"))
               (process-environment     ; to import emacs.py
                (cons (concat "PYTHONPATH="


reply via email to

[Prev in Thread] Current Thread [Next in Thread]