Clicking on error in Inferior Python mode jumps to wrong line after source file edit

Bug #1938612 reported by Al. Go.
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-mode.el
Invalid
Undecided
Unassigned

Bug Description

Description:

Editing the source file in Python mode before a line with an error results in the incorrect jump when clicking on the error line in inferior Python mode. Same when pressing RET on the error line. It seems that python-mode.el compensates for that edit twice (adding lines before the error sends me TOO FAR DOWN instead of up, by the amount of added lines). Reproducing with minimal example works 90% of the time, but not 100%. Tested with emacs -q, so it's not my .emacs config.

Versions:
$ emacs --version
GNU Emacs 26.1
$ apt-cache policy emacs
emacs:
  Installed: 1:26.1+1-3.2+deb10u2
$ uname -a
Linux [...] 4.19.0-17-amd64 #1 SMP Debian 4.19.194-2 (2021-06-21) x86_64 GNU/Linux

From C-h m in inferior mode:
Inferior Python mode defined in ‘python.el’
Clicking sends me to:
/usr/share/emacs/26.1/lisp/progmodes/python.el.gz

Steps to reproduce:

If I create a file t.py containing:

#1
assert False
#b
#c

Then visit it in emacs with Python mode and start an inferior Python mode with C-c C-p then run the file with C-c C-c, the inferior mode buffer shows:

"File "[...]/t.py", line 2, in <module>

Which is correct, and clicking on that line takes me to the "assert False" line in the Python mode buffer, which is correct.

BUT, if I then edit the source file by adding or removing lines before the error, for example:

#1
#2
assert False
#b
#c

the inferior mode buffer now shows:

"File "[...]/t.py", line 3, in <module>

Which is still correct, but clicking on it now sends me to line 4 (#b) instead of line 3. If I instead edit the file as such:

#1
#2
#3
assert False
#b
#c

the inferior mode buffer now shows:

"File "[...]/t.py", line 4, in <module>

But clicking on it now sends me to line 6 (#c), and so on.

Al. Go. (yupyup442)
description: updated
Revision history for this message
Andreas Roehler (a-roehler) wrote :

Here was python-mode.el, not python.el

Also all development has been moved to GitLab:

https://gitlab.com/python-mode-devs/python-mode

In your case, please do M-x report-emacs-bug RET

Changed in python-mode:
status: New → Invalid
Revision history for this message
Al. Go. (yupyup442) wrote :

Thank you and sorry for the mistake.

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.