Subject: bug#21193: closed (24.5; python.el: python-shell-buffer-substring fails under certain circumstances)

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 23 Aug 2015 23:02:03 +0000

Your bug report

#21086: 25.0.50; python-shell-buffer-substring adds bogus if True: to unindented line

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].

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

Subject: 24.5; python.el: python-shell-buffer-substring fails under certain circumstances
From: [email-masked] (Fabián Ezequiel Gallina)
To: [email-masked]
Date: Sun, 23 Aug 2015 20:01:15 -0300
List-Id: <debbugs-submit.debbugs.gnu.org>

Fixed in master at af013e0.

I installed a different patch that seems to be more robust on various
conditions (see tests).

Thanks for such detailed report,
Fabián.

Subject: 25.0.50; python-shell-buffer-substring adds bogus if True: to unindented line
From: Jorgen Schaefer <[email-masked]>
To: [email-masked]
Date: Wed, 05 Aug 2015 13:04:17 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello!

The function `python-shell-buffer-substring' can get confused when it is
used to send a substring of a line. It tries to add if True: around an
indented piece of code to prevent indentation errors, but it fails at
detecting indented code correctly:

(with-temp-buffer
  (insert "def foo():\n"
          "    print('a')\n")
  (re-search-backward "print")
  (python-shell-buffer-substring (point) (point-at-eol) t))

=>

"if True:
print('a')"

Note that the "print" line in the resulting code is not indented.

The expected result would be either "print('a')" or
"if True:\n    print('a')".

Regards,
Jorgen