Subject: bug#60142: 28.1; python.el Incorrect region when python-shell-send-region from indented code

From: Augusto Stoffel <[email-masked]>
Date: Mon, 19 Dec 2022 11:25:30 +0100

On Sun, 18 Dec 2022 at 12:39, Eli Zaretskii wrote:

>> If I select the `a` or `a = "test"` it will correctly send it to the
>> console, however it won't echo the evaluation of the statement.

I can at least explain why this happens and is expected.

An evaluation result is printed only if you send a bunch of statements,
the last of which is an expression.  OTOH, since whitespace is
significant in Python, if you evaluate anything that's not a "toplevel
form" it gets wrapper in a `if True:` statement, so the actually
evaluated code is not a simple expression anymore.

It seems hard to work around this limitation.