[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 112111c: Avoid infloop in python
From: |
Daniel Colascione |
Subject: |
[Emacs-diffs] master 112111c: Avoid infloop in python |
Date: |
Tue, 8 Nov 2016 23:26:55 +0000 (UTC) |
branch: master
commit 112111c4e489aae5cbe241ffa458d97b6a133d3a
Author: Daniel Colascione <address@hidden>
Commit: Daniel Colascione <address@hidden>
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 +++++++++--
test/lisp/progmodes/python-tests.el | 7 +++++++
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 290cdc8..f9b28c3 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)))))
diff --git a/test/lisp/progmodes/python-tests.el
b/test/lisp/progmodes/python-tests.el
index 54ed922..f6564dd 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 112111c: Avoid infloop in python,
Daniel Colascione <=