From: Lars Ingebrigtsen <larsi@gnus.org>
To: Gunnar Horrigmo <horrigmo@runbox.no>
Cc: 43450@debbugs.gnu.org
Subject: bug#43450: 28.0.50; Python shell doesn't echo if shebang
Date: Wed, 30 Sep 2020 18:50:16 +0200 [thread overview]
Message-ID: <87362z2oqf.fsf@gnus.org> (raw)
In-Reply-To: <iv4zh5pzwhh.fsf@hot-rats.uio.no> (Gunnar Horrigmo's message of "Wed, 16 Sep 2020 15:23:22 +0200")
Gunnar Horrigmo <horrigmo@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@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
next prev parent reply other threads:[~2020-09-30 16:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-16 13:23 bug#43450: 28.0.50; Python shell doesn't echo if shebang Gunnar Horrigmo
2020-09-30 16:50 ` Lars Ingebrigtsen [this message]
2020-10-02 3:33 ` Lars Ingebrigtsen
2020-10-02 3:40 ` Lars Ingebrigtsen
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87362z2oqf.fsf@gnus.org \
--to=larsi@gnus.org \
--cc=43450@debbugs.gnu.org \
--cc=horrigmo@runbox.no \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).