GNU bug report logs - #22663
25.0.91; python.el electric-indent misbehaviour with 'except:'

Previous Next

Package: emacs;

Reported by: Matthew Woodcraft <matthew <at> woodcraft.me.uk>

Date: Sun, 14 Feb 2016 17:14:02 UTC

Severity: minor

Tags: patch

Found in version 25.0.91

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 22663 in the body.
You can then email your comments to 22663 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#22663; Package emacs. (Sun, 14 Feb 2016 17:14:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Matthew Woodcraft <matthew <at> woodcraft.me.uk>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 14 Feb 2016 17:14:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Matthew Woodcraft <matthew <at> woodcraft.me.uk>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.0.91; python.el electric-indent misbehaviour with 'except:'
Date: Sun, 14 Feb 2016 17:13:18 +0000
If I have the following code and add the colon after the 'ValueError',
python.el's electric-indent helpfully dedents the 'except' line, but
also indents the line below.

def foo():
    try:
        a = int(s)
        except ValueError
    bar(a)

In practice this is never what I want to happen: if I'm adding
try/except around part of an existing function, the existing lines after
'except' are for the non-exceptional case.

(Seen in emacs 25.0.91; 24.5 is the same; checked with 'emacs -Q'.)


In GNU Emacs 25.0.91.1 (i586-pc-linux-gnu, GTK+ Version 3.14.5)
 of 2016-02-14, modified by Debian built on golux
Windowing system distributor 'The X.Org Foundation', version 11.0.11604000
System Description:	Debian GNU/Linux 8.3 (jessie)

Configured using:
 'configure --build i586-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/lib
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --with-pop=yes
 --enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/25.0.91/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/25.0.91/site-lisp:/usr/share/emacs/site-lisp
 --build i586-linux-gnu --prefix=/usr --sharedstatedir=/var/lib
 --libexecdir=/usr/lib --localstatedir=/var/lib
 --infodir=/usr/share/info --mandir=/usr/share/man --with-pop=yes
 --enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/25.0.91/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/25.0.91/site-lisp:/usr/share/emacs/site-lisp
 --with-x=yes --with-x-toolkit=gtk3 --with-toolkit-scroll-bars
 'CFLAGS=-g -O2 -fstack-protector-strong -Wformat
 -Werror=format-security -Wall -fno-omit-frame-pointer'
 CPPFLAGS=-D_FORTIFY_SOURCE=2 LDFLAGS=-Wl,-z,relro'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11

Important settings:
  value of $LC_CTYPE: en_GB.UTF-8
  locale-coding-system: utf-8-unix





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#22663; Package emacs. (Sun, 12 Feb 2017 17:33:03 GMT) Full text and rfc822 format available.

Message #8 received at 22663 <at> debbugs.gnu.org (full text, mbox):

From: Joel Rosdahl <joel <at> rosdahl.net>
To: 22663 <at> debbugs.gnu.org
Subject: python-mode: Fix electric indent bug after dedenting colon
Date: Sun, 12 Feb 2017 16:11:41 +0100
[Message part 1 (text/plain, inline)]
This fixes bug #22663 ("25.0.91; python.el electric-indent misbehaviour
with 'except:'"). Note that the bug is not restricted to "except:" but
affects all statements that are dedented by an electric colon.

For instance, entering a colon after "else" in

    if do:
        something()
        else
    outside

results in

    if do:
        something()
    else:
        outside

before the bug fix but

    if do:
        something()
    else:
    outside

after the bug fix.

-- Joel
[Message part 2 (text/html, inline)]
[0001-python-mode-Fix-electric-indent-bug-after-dedenting-.patch (text/x-patch, attachment)]

Added tag(s) patch. Request was from Joel Rosdahl <joel <at> rosdahl.net> to control <at> debbugs.gnu.org. (Sun, 03 Dec 2017 21:00:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#22663; Package emacs. (Thu, 27 Dec 2018 17:39:01 GMT) Full text and rfc822 format available.

Message #13 received at 22663 <at> debbugs.gnu.org (full text, mbox):

From: Joel Rosdahl <joel <at> rosdahl.net>
To: 22663 <at> debbugs.gnu.org
Subject: python-mode: Fix electric indent bug after dedenting colon
Date: Thu, 27 Dec 2018 18:38:09 +0100
[Message part 1 (text/plain, inline)]
It looks like the bug still exists in Emacs 26.1 and on latest master.

Attached is an updated patch with change log entries in the commit
message on suggested by
https://www.gnu.org/software/emacs/manual/html_node/emacs/Sending-Patches.html#Sending-Patches.
Please also note that the patch includes a test case update that
verifies that the bug has been fixed.

-- Joel
[0001-Fix-electric-indent-bug-in-python-mode-after-dedenti.patch (text/x-patch, attachment)]

Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sat, 05 Jan 2019 09:07:02 GMT) Full text and rfc822 format available.

Notification sent to Matthew Woodcraft <matthew <at> woodcraft.me.uk>:
bug acknowledged by developer. (Sat, 05 Jan 2019 09:07:02 GMT) Full text and rfc822 format available.

Message #18 received at 22663-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Joel Rosdahl <joel <at> rosdahl.net>
Cc: 22663-done <at> debbugs.gnu.org
Subject: Re: bug#22663: python-mode: Fix electric indent bug after dedenting
 colon
Date: Sat, 05 Jan 2019 11:05:43 +0200
> From: Joel Rosdahl <joel <at> rosdahl.net>
> Date: Thu, 27 Dec 2018 18:38:09 +0100
> 
> It looks like the bug still exists in Emacs 26.1 and on latest master.
> 
> Attached is an updated patch with change log entries in the commit
> message on suggested by
> https://www.gnu.org/software/emacs/manual/html_node/emacs/Sending-Patches.html#Sending-Patches.
> Please also note that the patch includes a test case update that
> verifies that the bug has been fixed.

Thanks, pushed to the master branch.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 02 Feb 2019 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 84 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.