1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 18:40:39 -08:00

Avoid infloop in python

Fix bug#24905

* lisp/progmodes/python.el (python-info-docstring-p): Improve
infloop avoidance: replace (bobp) with generic test for
forward progress.
* test/lisp/progmodes/python-tests.el (python-bob-infloop-avoid): Add
test for bug#24905
This commit is contained in:
Daniel Colascione 2016-11-08 15:26:43 -08:00
parent 06cfaa3dfa
commit 112111c4e4
2 changed files with 16 additions and 2 deletions

View file

@ -4892,12 +4892,19 @@ point's current `syntax-ppss'."
;; Allow up to two consecutive docstrings only.
(>=
2
(progn
(let (last-backward-sexp-point)
(while (save-excursion
(python-nav-backward-sexp)
(setq backward-sexp-point (point))
(and (= indentation (current-indentation))
(not (bobp)) ; Prevent infloop.
;; Make sure we're always moving point.
;; If we get stuck in the same position
;; on consecutive loop iterations,
;; bail out.
(prog1 (not (eql last-backward-sexp-point
backward-sexp-point))
(setq last-backward-sexp-point
backward-sexp-point))
(looking-at-p
(concat "[uU]?[rR]?"
(python-rx string-delimiter)))))