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:
parent
8da810f91b
commit
3ef4ee84fa
2 changed files with 16 additions and 2 deletions
|
@ -4865,12 +4865,19 @@ point's current `syntax-ppss'."
|
||||||
;; Allow up to two consecutive docstrings only.
|
;; Allow up to two consecutive docstrings only.
|
||||||
(>=
|
(>=
|
||||||
2
|
2
|
||||||
(progn
|
(let (last-backward-sexp-point)
|
||||||
(while (save-excursion
|
(while (save-excursion
|
||||||
(python-nav-backward-sexp)
|
(python-nav-backward-sexp)
|
||||||
(setq backward-sexp-point (point))
|
(setq backward-sexp-point (point))
|
||||||
(and (= indentation (current-indentation))
|
(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
|
(looking-at-p
|
||||||
(concat "[uU]?[rR]?"
|
(concat "[uU]?[rR]?"
|
||||||
(python-rx string-delimiter)))))
|
(python-rx string-delimiter)))))
|
||||||
|
|
|
@ -2452,6 +2452,13 @@ if x:
|
||||||
(line-beginning-position) (line-end-position))
|
(line-beginning-position) (line-end-position))
|
||||||
"abcdef")))))
|
"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
|
;;; Shell integration
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue