summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorDaniel Colascione <dancol@dancol.org>2016-11-08 15:26:43 -0800
committerDaniel Colascione <dancol@dancol.org>2016-11-08 15:26:43 -0800
commit112111c4e489aae5cbe241ffa458d97b6a133d3a (patch)
tree3de7ef225d0b2bd30eb475067851aacf89fd7fd0 /lisp
parent06cfaa3dfa1888b55df437a16ced6f718678bc56 (diff)
downloademacs-112111c4e489aae5cbe241ffa458d97b6a133d3a.tar.gz
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
Diffstat (limited to 'lisp')
-rw-r--r--lisp/progmodes/python.el11
1 files changed, 9 insertions, 2 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 290cdc8120d..f9b28c322c8 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -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)))))