GNU bug report logs - #43450
28.0.50; Python shell doesn't echo if shebang

Previous Next

Package: emacs;

Reported by: Gunnar Horrigmo <horrigmo <at> runbox.no>

Date: Wed, 16 Sep 2020 15:25:02 UTC

Severity: normal

Tags: fixed

Found in version 28.0.50

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 43450 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Gunnar Horrigmo <horrigmo <at> runbox.no>
Cc: Fabián Ezequiel Gallina <fgallina <at> gnu.org>,
 43450 <at> debbugs.gnu.org
Subject: Re: bug#43450: 28.0.50; Python shell doesn't echo if shebang
Date: Wed, 30 Sep 2020 18:50:16 +0200
Gunnar Horrigmo <horrigmo <at> runbox.no> writes:

> Open a .py file
> M-x run-python RET
> In .py file, write some statement, say "1+2" and evaluate it with
> (f.ex.) python-shell-send-statement. Observe that python shell echoes
> the result, "3", and prompts on a new line.
>
> Add a shebang to the top of .py file (f.ex. "#!/usr/bin/pyton3" on my
> system). Evaluate the same statement as over. Observe that python shell
> doesn't echo the result, but does print a new prompt, but without a
> newline. 

I can reproduce this in Emacs 28, but it doesn't seem to be triggered by
the shebang:  Adding some blank lines to the top of the buffer also
triggers the error.  Or ... anything:

(python-shell-buffer-substring 2 (point) nil)
=> "# -*- coding: utf-8 -*-

1+2"

(python-shell-buffer-substring 1 (point) nil)
=> "1+2"

         (fillstr (when (not starts-at-point-min-p)
                    (concat
                     (format "# -*- coding: %s -*-\n" encoding)
                     (make-string
                      ;; Subtract 2 because of the coding cookie.
                      (- (line-number-at-pos start) 2) ?\n)))))

This was added by (in a slightly different form):

commit 2dd5163d764f395eb31a2306dba385d123af4aba
Author:     Fabián Ezequiel Gallina <fgallina <at> gnu.org>
AuthorDate: Sat Dec 27 01:30:21 2014 -0300

    python.el: Handle file encoding for shell.
    
    * lisp/progmodes/python.el (python-rx-constituents): Add coding-cookie.
    (python-shell--save-temp-file): Write file with proper encoding.
    (python-shell-buffer-substring): Add coding cookie for detected
    encoding to generated content.  Fix blank lines when removing
    if-name-main block.
    (python-shell-send-file): Handle file encoding.
    (python-info-encoding-from-cookie)
    (python-info-encoding): New functions.

I've added Fabián to the Cc, perhaps he has some insight here...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




This bug report was last modified 4 years and 236 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.