An Emacs mode for editing Python code

incorrect indentation of one-line functions

Reported by Simon Safar on 2012-10-17
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-mode.el
Medium
Andreas Roehler

Bug Description

When indenting Python code, python-mode incorrectly indents functions whose first line is "return <something>" or "pass". For example, when having the code

def foo():
    pass

and pressing tab on the "pass" line, "pass" gets put to the beginning of the line, like this:

def foo():
pass

Later code is also affected:

class foo:
    def bar():
[here "pass" gets indented either in line with "def" or the beginning of the line]
    pass
[and here we only get the beginning of the line as the only indentation]

The phenomenon is present with both 6.0.12 and the newest development branch (that declares itself 6.0.13), with emacs 23 on both OSX and Ubuntu 12.04 (latter also tried on a relatively fresh VM), also starting with emacs -Q.

Steps to reproduce
--------------------------
1) load the file
(add-to-list 'load-path "~/path-to-python-mode")
(require 'python-mode)
2) open a new Python buffer
C-c C-f ~/test.py
3) enter code
def foo(): [press Enter, indentation is still correct, we stand in the next line on the 4th column]
4) enter "return" or "pass"
(and observe the indentation described above.)

Simon Safar (latanius) on 2012-10-17
description: updated
Changed in python-mode:
milestone: none → 6.1.0
assignee: nobody → Andreas Roehler (a-roehler)
importance: Undecided → Medium
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  Edit
Everyone can see this information.

Other bug subscribers