From: Noam Postavsky Date: Sat, 2 Jun 2018 20:22:17 +0000 (-0400) Subject: Fix off by one error in python-mode assertion (Bug#30964) X-Git-Tag: emacs-27.0.90~4825 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=05345babc988060cca540770599282102c34f2a7;p=emacs.git Fix off by one error in python-mode assertion (Bug#30964) * lisp/progmodes/python.el (python-nav-end-of-statement): Don't assert that string-start is strictly greater than last-string-end, because the string end is a position outside of the string and may therefore be the same as the following string's start. * test/lisp/progmodes/python-tests.el (python-nav-end-of-statement-2): New test. --- diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 6f4a343310c..e39ff08739b 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -1518,7 +1518,7 @@ of the statement." ;; are somehow out of whack. This has been ;; observed when using `syntax-ppss' during ;; narrowing. - (cl-assert (> string-start last-string-end) + (cl-assert (>= string-start last-string-end) :show-args "\ Overlapping strings detected (start=%d, last-end=%d)") diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index 1c4d22d72fa..0b9f8484c10 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -2004,6 +2004,12 @@ string (python-util-forward-comment -1) (point)))))) +(ert-deftest python-nav-end-of-statement-2 () + "Test the string overlap assertion (Bug#30964)." + (python-tests-with-temp-buffer + "'\n''\n" + (python-nav-end-of-statement))) + (ert-deftest python-nav-forward-statement-1 () (python-tests-with-temp-buffer "