Subject: bug#19823: closed (25.0.50; Inferior-python-mode buffer can't be killed if process is dead)

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 12 Feb 2015 03:43:02 +0000

Your bug report

#19823: 25.0.50; Inferior-python-mode buffer can't be killed if process is dead

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
19823: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=19823
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: 25.0.50; Inferior-python-mode buffer can't be killed if process is dead
From: [email-masked] (Fabián Ezequiel Gallina)
To: [email-masked]
Date: Thu, 12 Feb 2015 00:42:11 -0300
List-Id: <debbugs-submit.debbugs.gnu.org>

Fixed at revno da726ad in the master branch.

Thanks,
Fabián.

Subject: 25.0.50; Inferior-python-mode buffer can't be killed if process is dead
From: Dima Kogan <[email-masked]>
To: [email-masked]
Date: Mon, 09 Feb 2015 12:05:09 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi. Currently emacs requires the inferior python process to exist to be
able to kill that buffer. If the inferior process exits earlier for any
reason, it's impossible to kill the buffer. Recipe:

1. emacs -Q
2. M-x python
3. exit()       [ this exits the session, killing the inferior process ]
4. C-x k enter  [ Error! "No inferior Python process running" ]

This happens because a cleanup handler fails. It needs to explicitly
ignore this particular failure. Wrapping the contents of
python-shell-font-lock-kill-buffer() into (ignore-errors ....) is one
way to fix this:

(defun python-shell-font-lock-kill-buffer ()
  "Kill the font-lock buffer safely."
  (ignore-errors
    (python-shell-with-shell-buffer
      (when (and python-shell--font-lock-buffer
                 (buffer-live-p python-shell--font-lock-buffer))
        (kill-buffer python-shell--font-lock-buffer)
        (when (derived-mode-p 'inferior-python-mode)
          (setq python-shell--font-lock-buffer nil))))))

It should probably be more specific than a blanket ignore-errors, but
the maintainers should decide what they want here.