unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
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: Fri, 02 Oct 2020 05:40:37 +0200	[thread overview]
Message-ID: <87lfgpz45m.fsf@gnus.org> (raw)
In-Reply-To: <87r1qhz4i7.fsf@gnus.org> (Lars Ingebrigtsen's message of "Fri, 02 Oct 2020 05:33:04 +0200")

Lars Ingebrigtsen <larsi@gnus.org> writes:

> I have to admit that I don't understand the reason for the coding cookie
> at all -- we bind coding-system-for-write to utf-8 before writing the
> temp file anyway, and on the Python side, we specify the coding system
> explicitly there, too.

OK, I think this is basically the point of it all:

(defun python-shell--save-temp-file (string)
  (let* ((temporary-file-directory
          (if (file-remote-p default-directory)
              (concat (file-remote-p default-directory) "/tmp")
            temporary-file-directory))
         (temp-file-name (make-temp-file "py"))
         (coding-system-for-write (python-info-encoding)))
    (with-temp-file temp-file-name
      (insert string)
      (delete-trailing-whitespace))
    temp-file-name))

If the current buffer has a coding cookie, we use that in the temp files
we load, too.  That's logical (er, somewhat, why not just use the
current buffer coding system?), but if there's no coding cookie, we
still add one, which isn't.

Anyway, I think the change I made is unlikely to break anything...
possibly...  unless you have a Python file with a coding system cookie,
and you're eval-ing a non-ASCII string, and it's not all utf-8.

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





      reply	other threads:[~2020-10-02  3:40 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
2020-10-02  3:33   ` Lars Ingebrigtsen
2020-10-02  3:40     ` Lars Ingebrigtsen [this message]

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=87lfgpz45m.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).