GNU bug report logs - #65870
30.0.50; Error in python-mode when try to delete a character in badly-indented code

Previous Next

Package: emacs;

Reported by: Daniel Lopez <daniel.lopez999 <at> gmail.com>

Date: Mon, 11 Sep 2023 16:38:01 UTC

Severity: normal

Found in version 30.0.50

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

Bug is archived. No further changes may be made.

Full log


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

From: Jakub Ječmínek <kuba <at> kubajecminek.cz>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: kobarity <kobarity <at> gmail.com>, Daniel Lopez <daniel.lopez999 <at> gmail.com>,
 65870 <at> debbugs.gnu.org
Subject: Re: bug#65870: 30.0.50;
 Error in python-mode when try to delete a character in badly-indented
 code
Date: Sun, 02 Jun 2024 21:08:30 +0000
kobarity <kobarity <at> gmail.com> writes:

> Eli Zaretskii wrote:
>> kobarity, any suggestions or comments?
>
> Thank you for the report.  The attached is the proposed fix.
>
>>From 32f0dbe5f942ffa60f0945d2ffb771db82db5832 Mon Sep 17 00:00:00 2001
> From: kobarity <kobarity <at> gmail.com>
> Date: Sat, 16 Sep 2023 23:14:45 +0900
> Subject: [PATCH] Fix Python mode error caused by incorrect indentation
>
> * lisp/progmodes/python.el (python-indent--calculate-indentation):
> Guard against negative indentation.  (Bug #65870)
>
> * test/lisp/progmodes/python-tests.el
> (python-indent-badly-indented-block-end): New test.
> ---
>  lisp/progmodes/python.el            | 2 +-
>  test/lisp/progmodes/python-tests.el | 9 +++++++++
>  2 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
> index 4b940b3f13b..d7e49e225d8 100644
> --- a/lisp/progmodes/python.el
> +++ b/lisp/progmodes/python.el
> @@ -1660,7 +1660,7 @@ python-indent--calculate-indentation
>          (`(:after-block-end . ,start)
>           ;; Subtract one indentation level.
>           (goto-char start)
> -         (- (current-indentation) python-indent-offset))
> +         (max 0 (- (current-indentation) python-indent-offset)))
>          (`(:at-dedenter-block-start . ,_)
>           ;; List all possible indentation levels from opening blocks.
>           (let ((opening-block-start-points
> diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
> index a44a11896f0..f3456030975 100644
> --- a/test/lisp/progmodes/python-tests.el
> +++ b/test/lisp/progmodes/python-tests.el
> @@ -2081,6 +2081,15 @@ python-indent-after-bare-match
>     (python-tests-look-at "else:")
>     (should (= (python-indent-calculate-indentation) 4))))
>  
> +(ert-deftest python-indent-badly-indented-block-end ()
> +  "Test BUG 65870 regression."
> +  (python-tests-with-temp-buffer
> +   "
> +return
> +"
> +   (goto-char (point-max))
> +   (should (= (python-indent-calculate-indentation) 0))))
> +
>  
>  ;;; Filling

Eli, can you please install this?  I can still reproduce the original error.





This bug report was last modified 349 days ago.

Previous Next


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