Fix infinite loop when editing Python files
rhbz2187041
This commit is contained in:
parent
57bf08d2e1
commit
9e852a1606
10
emacs.spec
10
emacs.spec
@ -5,7 +5,7 @@ Summary: GNU Emacs text editor
|
|||||||
Name: emacs
|
Name: emacs
|
||||||
Epoch: 1
|
Epoch: 1
|
||||||
Version: 28.2
|
Version: 28.2
|
||||||
Release: 6%{?dist}
|
Release: 7%{?dist}
|
||||||
License: GPL-3.0-or-later AND CC0-1.0
|
License: GPL-3.0-or-later AND CC0-1.0
|
||||||
URL: http://www.gnu.org/software/emacs/
|
URL: http://www.gnu.org/software/emacs/
|
||||||
Source0: https://ftp.gnu.org/gnu/emacs/emacs-%{version}.tar.xz
|
Source0: https://ftp.gnu.org/gnu/emacs/emacs-%{version}.tar.xz
|
||||||
@ -34,6 +34,9 @@ Patch7: https://git.savannah.gnu.org/cgit/emacs.git/patch/?id=d48bb4874bc
|
|||||||
# backport of https://git.savannah.gnu.org/cgit/emacs.git/patch/?id=e59216d3be86918b995bd63273c851ebc6176a83
|
# backport of https://git.savannah.gnu.org/cgit/emacs.git/patch/?id=e59216d3be86918b995bd63273c851ebc6176a83
|
||||||
Patch8: native-compile-with_-Q.patch
|
Patch8: native-compile-with_-Q.patch
|
||||||
Patch9: webkit2gtk-4.1.patch
|
Patch9: webkit2gtk-4.1.patch
|
||||||
|
# Fix infinite loop error https://debbugs.gnu.org/cgi/bugreport.cgi?bug=58780
|
||||||
|
# Can be removed on next release of Emacs rhbz#2187041
|
||||||
|
Patch10: fix-searching-for-end-of-string-in-python-nav-end-of.patch
|
||||||
|
|
||||||
BuildRequires: gcc
|
BuildRequires: gcc
|
||||||
BuildRequires: atk-devel
|
BuildRequires: atk-devel
|
||||||
@ -222,6 +225,7 @@ cp -p %{SOURCE3} lib/
|
|||||||
%patch7 -p1 -b .ctags-local-execution-cve
|
%patch7 -p1 -b .ctags-local-execution-cve
|
||||||
%patch8 -p1 -b .native-compile-Q
|
%patch8 -p1 -b .native-compile-Q
|
||||||
%patch9 -p1 -b .webkit2gtk-4.1
|
%patch9 -p1 -b .webkit2gtk-4.1
|
||||||
|
%patch10 -p1
|
||||||
autoconf
|
autoconf
|
||||||
|
|
||||||
grep -v "tetris.elc" lisp/Makefile.in > lisp/Makefile.in.new \
|
grep -v "tetris.elc" lisp/Makefile.in > lisp/Makefile.in.new \
|
||||||
@ -546,6 +550,10 @@ desktop-file-validate %{buildroot}/%{_datadir}/applications/*.desktop
|
|||||||
%{_includedir}/emacs-module.h
|
%{_includedir}/emacs-module.h
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed May 31 2023 Benson Muite <benson_muite@emailplus.org> 1:28.2-7
|
||||||
|
- Apply patch to prevent infinite loops when editing python files
|
||||||
|
fixes rhbz#2187041
|
||||||
|
|
||||||
* Mon Apr 24 2023 Lukáš Zaoral <lzaoral@redhat.com> - 1:28.2-6
|
* Mon Apr 24 2023 Lukáš Zaoral <lzaoral@redhat.com> - 1:28.2-6
|
||||||
- migrate to SPDX license format
|
- migrate to SPDX license format
|
||||||
|
|
||||||
|
106
fix-searching-for-end-of-string-in-python-nav-end-of.patch
Normal file
106
fix-searching-for-end-of-string-in-python-nav-end-of.patch
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
From 62cfa24a89fdbf90cbe866ad88ca635327eb1f49 Mon Sep 17 00:00:00 2001
|
||||||
|
From: kobarity <kobarity@gmail.com>
|
||||||
|
Date: Sun, 5 Mar 2023 17:06:26 +0900
|
||||||
|
Subject: [PATCH 1/2] Fix searching for end of string in
|
||||||
|
python-nav-end-of-statement
|
||||||
|
|
||||||
|
* lisp/progmodes/python.el (python-nav-end-of-statement): Add
|
||||||
|
searching for corresponding string-quote.
|
||||||
|
* test/lisp/progmodes/python-tests.el (python-nav-end-of-statement-3)
|
||||||
|
(python-nav-end-of-statement-4, python-info-current-defun-4): New
|
||||||
|
tests. (Bug#58780)
|
||||||
|
---
|
||||||
|
lisp/progmodes/python.el | 14 ++++++---
|
||||||
|
test/lisp/progmodes/python-tests.el | 44 +++++++++++++++++++++++++++++
|
||||||
|
2 files changed, 54 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
|
||||||
|
index 1f970633bfc..cc4ece1669c 100644
|
||||||
|
--- a/lisp/progmodes/python.el
|
||||||
|
+++ b/lisp/progmodes/python.el
|
||||||
|
@@ -2076,10 +2076,16 @@ python-nav-end-of-statement
|
||||||
|
(goto-char (+ (point)
|
||||||
|
(python-syntax-count-quotes
|
||||||
|
(char-after (point)) (point))))
|
||||||
|
- (setq last-string-end
|
||||||
|
- (or (re-search-forward
|
||||||
|
- (rx (syntax string-delimiter)) nil t)
|
||||||
|
- (goto-char (point-max)))))))
|
||||||
|
+ (setq
|
||||||
|
+ last-string-end
|
||||||
|
+ (or (if (eq t (nth 3 (syntax-ppss)))
|
||||||
|
+ (re-search-forward
|
||||||
|
+ (rx (syntax string-delimiter)) nil t)
|
||||||
|
+ (ignore-error scan-error
|
||||||
|
+ (goto-char string-start)
|
||||||
|
+ (python-nav--lisp-forward-sexp)
|
||||||
|
+ (point)))
|
||||||
|
+ (goto-char (point-max)))))))
|
||||||
|
((python-syntax-context 'paren)
|
||||||
|
;; The statement won't end before we've escaped
|
||||||
|
;; at least one level of parenthesis.
|
||||||
|
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
|
||||||
|
index 4f24c042c6a..e9df4a2c843 100644
|
||||||
|
--- a/test/lisp/progmodes/python-tests.el
|
||||||
|
+++ b/test/lisp/progmodes/python-tests.el
|
||||||
|
@@ -2943,6 +2943,36 @@ python-nav-end-of-statement-2
|
||||||
|
"'\n''\n"
|
||||||
|
(python-nav-end-of-statement)))
|
||||||
|
|
||||||
|
+(ert-deftest python-nav-end-of-statement-3 ()
|
||||||
|
+ "Test unmatched quotes (Bug#58780)."
|
||||||
|
+ (python-tests-with-temp-buffer
|
||||||
|
+ "
|
||||||
|
+' \"\"\"
|
||||||
|
+v = 1
|
||||||
|
+"
|
||||||
|
+ (python-tests-look-at "v =")
|
||||||
|
+ (should (= (save-excursion
|
||||||
|
+ (python-nav-end-of-statement)
|
||||||
|
+ (point))
|
||||||
|
+ (save-excursion
|
||||||
|
+ (point-max))))))
|
||||||
|
+
|
||||||
|
+(ert-deftest python-nav-end-of-statement-4 ()
|
||||||
|
+ (python-tests-with-temp-buffer
|
||||||
|
+ "
|
||||||
|
+abc = 'a\\
|
||||||
|
+b\\
|
||||||
|
+c'
|
||||||
|
+d = '''d'''
|
||||||
|
+"
|
||||||
|
+ (python-tests-look-at "b\\")
|
||||||
|
+ (should (= (save-excursion
|
||||||
|
+ (python-nav-end-of-statement)
|
||||||
|
+ (point))
|
||||||
|
+ (save-excursion
|
||||||
|
+ (python-tests-look-at "c'")
|
||||||
|
+ (pos-eol))))))
|
||||||
|
+
|
||||||
|
(ert-deftest python-nav-forward-statement-1 ()
|
||||||
|
(python-tests-with-temp-buffer
|
||||||
|
"
|
||||||
|
@@ -5209,6 +5239,20 @@ python-info-current-defun-3
|
||||||
|
(should (string= (python-info-current-defun t)
|
||||||
|
"def decoratorFunctionWithArguments"))))
|
||||||
|
|
||||||
|
+(ert-deftest python-info-current-defun-4 ()
|
||||||
|
+ "Ensure unmatched quotes do not cause hang (Bug#58780)."
|
||||||
|
+ (python-tests-with-temp-buffer
|
||||||
|
+ "
|
||||||
|
+def func():
|
||||||
|
+ ' \"\"\"
|
||||||
|
+ v = 1
|
||||||
|
+"
|
||||||
|
+ (python-tests-look-at "v = 1")
|
||||||
|
+ (should (string= (python-info-current-defun)
|
||||||
|
+ "func"))
|
||||||
|
+ (should (string= (python-info-current-defun t)
|
||||||
|
+ "def func"))))
|
||||||
|
+
|
||||||
|
(ert-deftest python-info-current-symbol-1 ()
|
||||||
|
(python-tests-with-temp-buffer
|
||||||
|
"
|
||||||
|
--
|
||||||
|
2.34.1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user