py-execute-region: 'Indentation error' with multiple lines

Bug #1451600 reported by Emanuele Olivetti
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-mode.el
Fix Released
Wishlist
Andreas Roehler

Bug Description

With both emacs23 and emacs24, the latest python-mode in trunk raises 'IndentationError: unexpected indent' when issuing py-execute-region when multiple indented lines are selected.

To reproduce the issue, copy the following snippet in a buffer:
----
if __name__ == '__main__':
    print("one")
    print("two")
----
If you select the last two lines and issue py-execute-region I get:
----
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> >>> >>> >>> Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tmp/python-18790BVl.py", line 2
    print("two")
    ^
IndentationError: unexpected indent
>>> Traceback (most recent call last):
      File a.py, line 4
  File "/tmp/python-18790BVl.py", line 2
    print("two")
    ^
IndentationError: unexpected indent
----
(oddly the error appears twice)

Notice that py-execute-buffer works correctly when selecting all three lines of the snippet, or when selecting just one line - indented or not.

Changed in python-mode:
assignee: nobody → Andreas Roehler (a-roehler)
importance: Undecided → Wishlist
status: New → In Progress
Revision history for this message
Andreas Roehler (a-roehler) wrote :

Please re-open if not done. There some issues WRT tests. Command itself should work.

Changed in python-mode:
status: In Progress → Fix Committed
milestone: none → 6.2.1
Revision history for this message
Emanuele Olivetti (emanuele-relativita) wrote :

After pulling the latest changes, unfortunately, python-mode does not work for me. Most of the functions (py-execute-...) do not work and keep stating instead:
  Symbol's function definition is void: py-execute-region

My .emacs is:
  (add-to-list 'load-path "/home/emanuele/emacs/python-mode/")
  (setq py-install-directory "/home/emanuele/emacs/python-mode/")
  (require 'python-mode)
  (require 'ipython)
  (setq python-shell-interpreter "ipython")

Changed in python-mode:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.