Package: emacs25
Version: 25.1+1-4
Severity: normal
Tags: patch

Dear Maintainer,

emacs25 runs into an infinite loop in python-mode that can be
triggered with:

  $ emacs25 -Q test.py --eval '(insert " \"")'

which makes python-mode and other modes that use it rather unpleasant
to use.

This bug has been reported upstream [0] and a patch is included in
25.2 which, unfortunately, didn't make it into stretch.

[0] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=24856

It would be appreciated if the attached patch could be included in
stretch.

Thank you and may you have a nice day

Wolodja

-- System Information:
Debian Release: 9.0
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (1, 'experimental')
Architecture: amd64
 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.9.0-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_GB.utf-8, LC_CTYPE=en_GB.utf-8 (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages emacs25 depends on:
ii  emacs25-bin-common     25.1+1-4
ii  gconf-service          3.2.6-4+b1
ii  libacl1                2.2.52-3+b1
ii  libasound2             1.1.3-5
ii  libatk1.0-0            2.22.0-1
ii  libc6                  2.24-10
ii  libcairo-gobject2      1.14.8-1
ii  libcairo2              1.14.8-1
ii  libdbus-1-3            1.10.18-1
ii  libfontconfig1         2.11.0-6.7+b1
ii  libfreetype6           2.6.3-3.2
ii  libgconf-2-4           3.2.6-4+b1
ii  libgdk-pixbuf2.0-0     2.36.5-2
ii  libgif7                5.1.4-0.4
ii  libglib2.0-0           2.50.3-2
ii  libgnutls30            3.5.8-5
ii  libgomp1               6.3.0-16
ii  libgpm2                1.20.4-6.2+b1
ii  libgtk-3-0             3.22.12-1
ii  libice6                2:1.0.9-2
ii  libjpeg62-turbo        1:1.5.1-2
ii  libm17n-0              1.7.0-3+b1
ii  libmagickcore-6.q16-3  8:6.9.7.4+dfsg-6
ii  libmagickwand-6.q16-3  8:6.9.7.4+dfsg-6
ii  libotf0                0.9.13-3+b1
ii  libpango-1.0-0         1.40.5-1
ii  libpangocairo-1.0-0    1.40.5-1
ii  libpng16-16            1.6.28-1
ii  librsvg2-2             2.40.16-1+b1
ii  libselinux1            2.6-3+b1
ii  libsm6                 2:1.2.2-1+b3
ii  libtiff5               4.0.7-6
ii  libtinfo5              6.0+20161126-1
ii  libx11-6               2:1.6.4-3
ii  libx11-xcb1            2:1.6.4-3
ii  libxcb1                1.12-1
ii  libxfixes3             1:5.0.3-1
ii  libxft2                2.3.2-1+b2
ii  libxinerama1           2:1.1.3-1+b3
ii  libxml2                2.9.4+dfsg1-2.2
ii  libxpm4                1:3.5.12-1
ii  libxrandr2             2:1.5.1-1
ii  libxrender1            1:0.9.10-1
ii  zlib1g                 1:1.2.8.dfsg-5

emacs25 recommends no packages.

Versions of packages emacs25 suggests:
ii  emacs25-common-non-dfsg  25.1+1-1

-- no debconf information
>From 5da4f196fc3c8b411936551568477d70a9046421 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npost...@gmail.com>
Date: Wed, 2 Nov 2016 21:59:10 -0400
Subject: [PATCH v1] Fix infloop in python docstring detection

The function `python-info-docstring-p' (introduced in 2015-04-05
"python.el: Enhance docstring detection following PEP-257[...]") could
get stuck when called with point before the first expression in the
buffer.  The attempted fix in 2015-04-06 "Fix previous commit to prevent
infloop" did not handle the case where there is only whitespace between
the first expression and the beginning of buffer (Bug#24856, Bug#24839).

* lisp/progmodes/python.el (python-info-docstring-p): Stop looping when
`python-nav-backward-sexp' fails to move point.
---
 lisp/progmodes/python.el | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index e5efc2b..de06efb 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -4867,13 +4867,14 @@ python-info-docstring-p
               2
               (progn
                 (while (save-excursion
-                         (python-nav-backward-sexp)
-                         (setq backward-sexp-point (point))
-                         (and (= indentation (current-indentation))
-                              (not (bobp)) ; Prevent infloop.
-                              (looking-at-p
-                               (concat "[uU]?[rR]?"
-                                       (python-rx string-delimiter)))))
+                         (let ((cur-point (point)))
+                           (python-nav-backward-sexp)
+                           (setq backward-sexp-point (point))
+                           (and (= indentation (current-indentation))
+                                (/= cur-point (point)) ; Prevent infloop.
+                                (looking-at-p
+                                 (concat "[uU]?[rR]?"
+                                         (python-rx string-delimiter))))))
                   ;; Previous sexp was a string, restore point.
                   (goto-char backward-sexp-point)
                   (cl-incf counter))
-- 
2.9.3

Reply via email to