[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#21376: 25.0.50; Python tests fail on MS-Windows -- issues with the p
From: |
npostavs |
Subject: |
bug#21376: 25.0.50; Python tests fail on MS-Windows -- issues with the prompt |
Date: |
Tue, 15 Aug 2017 21:41:18 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) |
tags 21376 + patch
quit
Eli Zaretskii <eliz@gnu.org> writes:
> 4 of the Python tests fail on MS-Windows due to some issue related to
> the prompts displayed by the Python interpreter. The 4 failed tests
> are:
>
> FAILED python-shell-make-comint-4
> FAILED python-shell-prompt-detect-1
> FAILED python-shell-prompt-detect-2
> FAILED python-shell-prompt-set-calculated-regexps-6
>
> I show below the relevant portions of python-tests.log.
>
> I need help in figuring out what causes these. One possible suspect
> is some buffering issue, due to which Emacs does not receive the
> prompt that Python prints. Another possibility might be the version
> of the Python (I have 2.6.6 installed). Or maybe something else.
It seems to be a bug in Python 2.x on Windows (Python 3.6.x doesn't show
the problem). In unbuffered mode it rejects carriage returns. Compare
results of
printf 'print("hello world")\r\n' > hello-world-with-crnl.py
python -i < hello-world-with-crnl.py
python -i -u < hello-world-with-crnl.py
printf 'print("hello world")\n' > hello-world-with-nl.py
python -i < hello-world-with-nl.py
python -i -u < hello-world-with-nl.py
(Setting the PYTHONUNBUFFERED environment variable, as python.el does,
is equivalent to passing '-u'.)
The bug can be worked around with the following patch:
>From a8b2295d38f50044e0396c29aefd5f465e848c84 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Tue, 15 Aug 2017 17:49:10 -0400
Subject: [PATCH v1] Work around w32-python-2.7 bug to fix prompt detection
(Bug#21376)
* lisp/progmodes/python.el (python-shell-prompt-detect): Don't put
carriage returns into the temporary file when running in unbuffered
mode, the w32 build of python 2.7 chokes on them.
---
lisp/progmodes/python.el | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index d774874a43..b7385f870f 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -2251,7 +2251,11 @@ python-shell-prompt-detect
;; `condition-case' and displaying the error message to
;; the user in the no-prompts warning.
(ignore-errors
- (let ((code-file (python-shell--save-temp-file code)))
+ (let ((code-file
+ ;; Python 2.7 on Windows does not handle
+ ;; carriage returns in unbuffered mode.
+ (let ((inhibit-eol-conversion (getenv
"PYTHONUNBUFFERED")))
+ (python-shell--save-temp-file code))))
;; Use `process-file' as it is remote-host friendly.
(process-file
interpreter
--
2.14.1
- bug#21376: 25.0.50; Python tests fail on MS-Windows -- issues with the prompt,
npostavs <=