aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorFabián Ezequiel Gallina2014-11-22 20:09:30 -0300
committerFabián Ezequiel Gallina2014-11-22 20:09:30 -0300
commit238c052fdb9da3b1f96c09809461b70813c5bebc (patch)
tree11fe1953832ceba6980ef0215383b36131d37ad9 /lisp
parentbd3625c432ee3d05ae4316d3b0ad2c0225e6d532 (diff)
downloademacs-238c052fdb9da3b1f96c09809461b70813c5bebc.tar.gz
emacs-238c052fdb9da3b1f96c09809461b70813c5bebc.zip
Set PYTHONUNBUFFERED on shell startup.
Fixes: debbugs:18595 * lisp/progmodes/python.el (python-shell-unbuffered): New var. (python-shell-calculate-process-environment): Use it. * test/automated/python-tests.el (python-shell-calculate-process-environment-4) (python-shell-calculate-process-environment-5): New tests. (python-shell-make-comint-3): Use file-equal-p. (python-shell-get-or-create-process-1) (python-shell-get-or-create-process-2) (python-shell-get-or-create-process-3): Fix interpreter for Windows.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/progmodes/python.el22
2 files changed, 23 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 0f16eabdc03..e59c3910fd7 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12014-11-22 Fabián Ezequiel Gallina <fgallina@gnu.org>
2
3 Set PYTHONUNBUFFERED on shell startup.
4
5 * progmodes/python.el (python-shell-unbuffered): New var.
6 (python-shell-calculate-process-environment): Use it.
7
12014-11-22 Michael Albinus <michael.albinus@gmx.de> 82014-11-22 Michael Albinus <michael.albinus@gmx.de>
2 9
3 * net/tramp.el (tramp-action-password): Clean password on subsequent 10 * net/tramp.el (tramp-action-password): Clean password on subsequent
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 5a5a039afc9..4c27136f3b5 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -94,13 +94,13 @@
94;; python-shell-interpreter-args 94;; python-shell-interpreter-args
95;; "-i C:\\Python27\\Scripts\\ipython-script.py") 95;; "-i C:\\Python27\\Scripts\\ipython-script.py")
96 96
97;; If you are experiencing missing or delayed output in your shells, 97;; Missing or delayed output used to happen due to differences between
98;; that's likely caused by your Operating System's pipe buffering 98;; Operating Systems' pipe buffering (e.g. CPython 3.3.4 in Windows 7.
99;; (e.g. this is known to happen running CPython 3.3.4 in Windows 7.
100;; See URL `http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17304'). To 99;; See URL `http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17304'). To
101;; fix this, using CPython's "-u" commandline argument or setting the 100;; avoid this, the `python-shell-unbuffered' defaults to non-nil and
102;; "PYTHONUNBUFFERED" environment variable should help: See URL 101;; controls whether `python-shell-calculate-process-environment'
103;; `https://docs.python.org/3/using/cmdline.html#cmdoption-u'. 102;; should set the "PYTHONUNBUFFERED" environment variable on startup:
103;; See URL `https://docs.python.org/3/using/cmdline.html#cmdoption-u'.
104 104
105;; The interaction relies upon having prompts for input (e.g. ">>> " 105;; The interaction relies upon having prompts for input (e.g. ">>> "
106;; and "... " in standard Python shell) and output (e.g. "Out[1]: " in 106;; and "... " in standard Python shell) and output (e.g. "Out[1]: " in
@@ -1813,6 +1813,14 @@ Restart the Python shell after changing this variable for it to take effect."
1813 :group 'python 1813 :group 'python
1814 :safe 'booleanp) 1814 :safe 'booleanp)
1815 1815
1816(defcustom python-shell-unbuffered t
1817 "Should shell output be unbuffered?.
1818When non-nil, this may prevent delayed and missing output in the
1819Python shell. See commentary for details."
1820 :type 'boolean
1821 :group 'python
1822 :safe 'booleanp)
1823
1816(defcustom python-shell-process-environment nil 1824(defcustom python-shell-process-environment nil
1817 "List of environment variables for Python shell. 1825 "List of environment variables for Python shell.
1818This variable follows the same rules as `process-environment' 1826This variable follows the same rules as `process-environment'
@@ -2087,6 +2095,8 @@ uniqueness for different types of configurations."
2087 (virtualenv (if python-shell-virtualenv-path 2095 (virtualenv (if python-shell-virtualenv-path
2088 (directory-file-name python-shell-virtualenv-path) 2096 (directory-file-name python-shell-virtualenv-path)
2089 nil))) 2097 nil)))
2098 (when python-shell-unbuffered
2099 (setenv "PYTHONUNBUFFERED" "1"))
2090 (when python-shell-extra-pythonpaths 2100 (when python-shell-extra-pythonpaths
2091 (setenv "PYTHONPATH" 2101 (setenv "PYTHONPATH"
2092 (format "%s%s%s" 2102 (format "%s%s%s"