GNU bug report logs - #62031
29.0.60; python-mode indentation after re.match

Previous Next

Package: emacs;

Reported by: Rob Moss <robm.dev <at> gmail.com>

Date: Tue, 7 Mar 2023 08:55:01 UTC

Severity: normal

Found in version 29.0.60

Done: Dmitry Gutov <dgutov <at> yandex.ru>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Lele Gaifax <lele <at> metapensiero.it>
To: 62031 <at> debbugs.gnu.org
Cc: Rob Moss <robm.dev <at> gmail.com>, Dmitry Gutov <dgutov <at> yandex.ru>
Subject: bug#62031: 29.0.60; python-mode indentation after re.match
Date: Wed, 08 Mar 2023 08:53:19 +0100
I had a quick glance at this, and while I can confirm the problem with
the following test

    diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
    index 4f24c042c6a..9926c4b002f 100644
    --- a/test/lisp/progmodes/python-tests.el
    +++ b/test/lisp/progmodes/python-tests.el
    @@ -1982,6 +1982,17 @@ python-virt-bin
        (should (eq (car (python-indent-context)) :after-block-start))
        (should (= (python-indent-calculate-indentation) 8))))

    +(ert-deftest python-indent-after-re-match ()
    +  "Test BUG 62031 regression."
    +  (python-tests-with-temp-buffer
    +   "
    +def test_re(string):
    +    if re.match('^[a-c]+$', string):
    +        print('yes')
    +    else:
    +"
    +   (python-tests-look-at "else:")
    +   (should (= (python-indent-calculate-indentation) 4))))

I could not figure out how this can be fixed, with my current knowledge
on python.el.

There are several places where the regexp produced by `(python-rx
block-start)' is used, many within a `(looking-at ...)' form and several
others in a `(re-search-forward ...)': given that block starting
"keywords" are required to be at the beginning of a line, possibly
preceded by whitespace, I think that the problem may arise from those
usages which do not explicitly enforce the constraint, but unfortunately
all my attempts to do that a) didn't make the test above green and b)
broke one or more of the other tests.

I will try again, but I'm afraid this will go beyond my current spare
time availability.

bye, lele.




This bug report was last modified 2 years and 134 days ago.

Previous Next


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