Interactively, we want M-x run-python to focus the interpreter buffer.
The previous code failed in two ways:
- the call to 'display-buffer' was not reached if an interpreter
was already running,
- set-buffer is ineffectual if the interpreter's window is not
selected: once Emacs returns to the command loop, the current buffer
will revert back to what the selected window contains.
* lisp/progmodes/python.el (python-shell-make-comint): Handle the SHOW
argument regardless of whether an interpreter buffer exists, and use
pop-to-buffer to select the window.
(run-python): Delegate buffer management to
'python-shell-make-comint'.
* test/lisp/progmodes/python-tests.el
(python-tests--run-python-selects-window): Rename from
'python-tests--bug31398', and adjust assertions (bug#52380).