Comment 0 for bug 1067633

Revision history for this message
Simon Safar (latanius) wrote :

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