Commit 112111c4 authored by Daniel Colascione's avatar Daniel Colascione
Browse files

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
parent 06cfaa3d
......@@ -4892,12 +4892,19 @@ point's current `syntax-ppss'."
;; Allow up to two consecutive docstrings only.
(let (last-backward-sexp-point)
(while (save-excursion
(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
(setq last-backward-sexp-point
(concat "[uU]?[rR]?"
(python-rx string-delimiter)))))
......@@ -2452,6 +2452,13 @@ if x:
(line-beginning-position) (line-end-position))
(ert-deftest python-bob-infloop-avoid ()
"Test that strings at BOB don't confuse syntax analysis. Bug#24905"
" \"\n"
(goto-char (point-min))
;;; Shell integration
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment