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.el22
1 files changed, 16 insertions, 6 deletions
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"