Nested def wrong match

Bug #1594263 reported by Andreas Roehler on 2016-06-20
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-mode.el
Medium
Andreas Roehler

Bug Description

<email address hidden>

On 19.06.2016 06:52, Dima Kogan wrote:
> Hi. The current way python-mode handles nested functions seems wrong to
> me. I had thought that it was a bug, but the test suite explicitly
> checks for the current behavior, so I want to ask about it here before
> proposing a patch.
>
> This is the first check in the (python-nav-beginning-of-defun-1) test in
> test/automated/python-tests.el. Let's say you have a python buffer:
>
> def decoratorFunctionWithArguments(arg1, arg2, arg3):
> '''print decorated function call data to stdout.
>
> Usage:
>
> @decoratorFunctionWithArguments('arg1', 'arg2')
> def func(a, b, c=True):
> pass
> '''
>
> def wwrap(f):
> print 'Inside wwrap()'
> def wrapped_f(*args):
> print 'Inside wrapped_f()'
> print 'Decorator arguments:', arg1, arg2, arg3
> f(*args)
> print 'After f(*args)'
> return wrapped_f
> return wwrap
>
> The point is on "return wrapped_f". The user then hits C-M-a to navigate
> to the beginning of the current function. The point is unambiguously
> inside wwrap() and not inside wrapped_f(), so I claim it should end up
> at the "def wwrap(f)" line. However the current behavior (and that test
> suite check) say it should end up on "def "wrapped_f()".
>
> This seems wrong. In fact, there are two different "go-to-previous-def"
> functions: one that supposedly handles nested defuns
> (python-nav-beginning-of-defun) and one that doesn't
> (python-nav-backward-defun), and it doesn't make sense that they both do
> the same thing here.
>
> I propose to make C-M-a to go to "def wwrap" here. I already have the
> patches ready, but the test case is giving me pause.
>
> dima
>

Get the bug here too.

Changed in python-mode:
importance: Undecided → Medium
status: New → Confirmed
assignee: nobody → Andreas Roehler (a-roehler)
milestone: none → 6.2.3
Changed in python-mode:
status: Confirmed → Fix Committed
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers