Regression in py-execute-region

Bug #962227 reported by Barry Warsaw
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-mode.el
Fix Released
Medium
Andreas Roehler

Bug Description

Take the following code example:

def foo():
    def bar():
        return True
    return bar

In the past it was possible to highlight the middle two lines and run py-execute-region. This would have the effect of defining bar() at global scope, but that's okay since it was explicitly asked for. Now however you get this error in the Python buffer:

>>> Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tmp/Python4249aED.py", line 8
    return True
         ^
IndentationError: expected an indented block

which perhaps makes sense, but isn't helpful. What python-mode used to do was, if the block to be executed was indented, it would still a "if True:" line indented to column zero in front of the region to be executed. This is essentially a no-op that just makes the indented region valid syntactically. Perhaps this could be resurrected?

Changed in python-mode:
importance: Undecided → Medium
assignee: nobody → Andreas Roehler (a-roehler)
milestone: none → 6.0.6
status: New → Confirmed
Changed in python-mode:
status: Confirmed → Fix Committed
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.