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.
(>=
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)))))
......
......@@ -2452,6 +2452,13 @@ if x:
(line-beginning-position) (line-end-position))
"abcdef")))))
(ert-deftest python-bob-infloop-avoid ()
"Test that strings at BOB don't confuse syntax analysis. Bug#24905"
(python-tests-with-temp-buffer
" \"\n"
(goto-char (point-min))
(font-lock-fontify-buffer)))
;;; 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