* 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.
(cherry picked from commit
c03cafba390603de653def097fdcf9566d502061)
(`(: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
(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))))
+
\f
;;; Filling