From 3ef4ee84fa3f658c2df802569dc89023d98e9947 Mon Sep 17 00:00:00 2001 From: Daniel Colascione Date: Tue, 8 Nov 2016 15:26:43 -0800 Subject: 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 --- lisp/progmodes/python.el | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lisp/progmodes/python.el') diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 9091289b62e..d0d4a7f766e 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -4865,12 +4865,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))))) -- cgit v1.2.1