all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: npostavs@users.sourceforge.net
To: Eli Zaretskii <eliz@gnu.org>
Cc: 21376@debbugs.gnu.org
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	[thread overview]
Message-ID: <87mv70z3up.fsf@users.sourceforge.net> (raw)
In-Reply-To: <83bndq2slu.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 29 Aug 2015 15:21:01 +0300")

[-- Attachment #1: Type: text/plain, Size: 1354 bytes --]

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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1440 bytes --]

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


  parent reply	other threads:[~2017-08-16  1:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-29 12:21 bug#21376: 25.0.50; Python tests fail on MS-Windows -- issues with the prompt Eli Zaretskii
2015-09-11  7:58 ` Eli Zaretskii
2017-08-16  1:41 ` npostavs [this message]
2017-08-16 14:26   ` Eli Zaretskii
2017-08-16 16:14     ` Noam Postavsky
2017-08-16 16:38       ` Eli Zaretskii
2017-08-16 16:59         ` Noam Postavsky
2017-08-16 17:27           ` Eli Zaretskii
2017-08-20 20:50             ` npostavs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mv70z3up.fsf@users.sourceforge.net \
    --to=npostavs@users.sourceforge.net \
    --cc=21376@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.