* fix infinite loop in python.el
@ 2007-07-21 12:49 Paul Pogonyshev
2007-07-22 1:49 ` Richard Stallman
0 siblings, 1 reply; 6+ messages in thread
From: Paul Pogonyshev @ 2007-07-21 12:49 UTC (permalink / raw)
To: emacs-devel
Hi,
This patch fixes possible infinite loop (apparently happening only
with invalid syntax) in `python.el'. I accidentally discovered it
when Emacs would hang with new `python-which-func'.
2007-07-21 Paul Pogonyshev <pogonyshev@gmx.net>
* progmodes/python.el (python-current-defun): Adjust to never fall
into infinite loop.
*** python.el 12 Jul 2007 22:55:32 +0300 1.63
--- python.el 21 Jul 2007 15:46:18 +0300
***************
*** 1828,1848 ****
(save-excursion
;; Move up the tree of nested `class' and `def' blocks until we
;; get to zero indentation, accumulating the defined names.
! (let ((start t)
! (accum)
(length -1))
! (while (and (or start (> (current-indentation) 0))
! (or (null length-limit)
! (null (cdr accum))
! (< length length-limit)))
! (setq start nil)
! (python-beginning-of-block)
! (end-of-line)
! (beginning-of-defun)
! (when (looking-at (rx (0+ space) (or "def" "class") (1+ space)
! (group (1+ (or word (syntax symbol))))))
! (push (match-string 1) accum)
! (setq length (+ length 1 (length (car accum))))))
(when accum
(when (and length-limit (> length length-limit))
(setcar accum ".."))
--- 1828,1852 ----
(save-excursion
;; Move up the tree of nested `class' and `def' blocks until we
;; get to zero indentation, accumulating the defined names.
! (let ((accum)
(length -1))
! (catch 'done
! (while (or (null length-limit)
! (null (cdr accum))
! (< length length-limit))
! (setq start nil)
! (let ((started-from (point)))
! (python-beginning-of-block)
! (end-of-line)
! (beginning-of-defun)
! (when (= (point) started-from)
! (throw 'done nil)))
! (when (looking-at (rx (0+ space) (or "def" "class") (1+ space)
! (group (1+ (or word (syntax symbol))))))
! (push (match-string 1) accum)
! (setq length (+ length 1 (length (car accum)))))
! (when (= (current-indentation) 0)
! (throw 'done nil))))
(when accum
(when (and length-limit (> length length-limit))
(setcar accum ".."))
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: fix infinite loop in python.el
2007-07-21 12:49 fix infinite loop in python.el Paul Pogonyshev
@ 2007-07-22 1:49 ` Richard Stallman
2007-07-22 16:45 ` Paul Pogonyshev
0 siblings, 1 reply; 6+ messages in thread
From: Richard Stallman @ 2007-07-22 1:49 UTC (permalink / raw)
To: Paul Pogonyshev; +Cc: emacs-devel
Does the bug exist in Emacs 22, or only in the trunk?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: fix infinite loop in python.el
2007-07-22 1:49 ` Richard Stallman
@ 2007-07-22 16:45 ` Paul Pogonyshev
2007-07-23 4:28 ` Richard Stallman
0 siblings, 1 reply; 6+ messages in thread
From: Paul Pogonyshev @ 2007-07-22 16:45 UTC (permalink / raw)
To: emacs-devel, rms
Richard Stallman wrote:
> Does the bug exist in Emacs 22, or only in the trunk?
Don't know. As far as I can tell, it was also present in 22, but just
never manifested itself. It became uncovered due to this change, but
probably was not added by the change:
2007-07-12 Paul Pogonyshev <pogonyshev@gmx.net>
* progmodes/which-func.el (which-func-modes): Add `python-mode'.
* progmodes/python.el (python-which-func-length-limit): New var.
(python-which-func): New function.
(python-current-defun): Add optional `length-limit' and try to fit
computed function name to that length.
(python-mode): Hook `python-which-func' up.
It did alter the function in question, but as far as I can see,
infinite loop was possible before too.
Paul
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: fix infinite loop in python.el
2007-07-22 16:45 ` Paul Pogonyshev
@ 2007-07-23 4:28 ` Richard Stallman
2007-07-31 13:56 ` Paul Pogonyshev
0 siblings, 1 reply; 6+ messages in thread
From: Richard Stallman @ 2007-07-23 4:28 UTC (permalink / raw)
To: Paul Pogonyshev; +Cc: emacs-devel
I guess we may as well install the change in Emacs 22.
If nobody installs it in a few days, would you please remind people
until they do?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: fix infinite loop in python.el
2007-07-23 4:28 ` Richard Stallman
@ 2007-07-31 13:56 ` Paul Pogonyshev
2007-08-01 0:49 ` Vinicius Jose Latorre
0 siblings, 1 reply; 6+ messages in thread
From: Paul Pogonyshev @ 2007-07-31 13:56 UTC (permalink / raw)
To: emacs-devel, rms
Richard Stallman wrote:
> I guess we may as well install the change in Emacs 22.
>
> If nobody installs it in a few days, would you please remind people
> until they do?
Can someone install this?
2007-07-21 Paul Pogonyshev <pogonyshev@gmx.net>
* progmodes/python.el (python-current-defun): Adjust to never fall
into infinite loop.
*** python.el 12 Jul 2007 22:55:32 +0300 1.63
--- python.el 21 Jul 2007 15:46:18 +0300
***************
*** 1828,1848 ****
(save-excursion
;; Move up the tree of nested `class' and `def' blocks until we
;; get to zero indentation, accumulating the defined names.
! (let ((start t)
! (accum)
(length -1))
! (while (and (or start (> (current-indentation) 0))
! (or (null length-limit)
! (null (cdr accum))
! (< length length-limit)))
! (setq start nil)
! (python-beginning-of-block)
! (end-of-line)
! (beginning-of-defun)
! (when (looking-at (rx (0+ space) (or "def" "class") (1+ space)
! (group (1+ (or word (syntax symbol))))))
! (push (match-string 1) accum)
! (setq length (+ length 1 (length (car accum))))))
(when accum
(when (and length-limit (> length length-limit))
(setcar accum ".."))
--- 1828,1852 ----
(save-excursion
;; Move up the tree of nested `class' and `def' blocks until we
;; get to zero indentation, accumulating the defined names.
! (let ((accum)
(length -1))
! (catch 'done
! (while (or (null length-limit)
! (null (cdr accum))
! (< length length-limit))
! (setq start nil)
! (let ((started-from (point)))
! (python-beginning-of-block)
! (end-of-line)
! (beginning-of-defun)
! (when (= (point) started-from)
! (throw 'done nil)))
! (when (looking-at (rx (0+ space) (or "def" "class") (1+ space)
! (group (1+ (or word (syntax symbol))))))
! (push (match-string 1) accum)
! (setq length (+ length 1 (length (car accum)))))
! (when (= (current-indentation) 0)
! (throw 'done nil))))
(when accum
(when (and length-limit (> length length-limit))
(setcar accum ".."))
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: fix infinite loop in python.el
2007-07-31 13:56 ` Paul Pogonyshev
@ 2007-08-01 0:49 ` Vinicius Jose Latorre
0 siblings, 0 replies; 6+ messages in thread
From: Vinicius Jose Latorre @ 2007-08-01 0:49 UTC (permalink / raw)
To: Paul Pogonyshev; +Cc: rms, emacs-devel
Paul Pogonyshev wrote:
> Richard Stallman wrote:
>
>> I guess we may as well install the change in Emacs 22.
>>
>> If nobody installs it in a few days, would you please remind people
>> until they do?
>>
>
> Can someone install this?
>
Done.
This patch applies only in trunk, not in Emacs 22 branch.
> 2007-07-21 Paul Pogonyshev <pogonyshev@gmx.net>
>
> * progmodes/python.el (python-current-defun): Adjust to never fall
> into infinite loop.
>
>
> *** python.el 12 Jul 2007 22:55:32 +0300 1.63
> --- python.el 21 Jul 2007 15:46:18 +0300
> ***************
> *** 1828,1848 ****
> (save-excursion
> ;; Move up the tree of nested `class' and `def' blocks until we
> ;; get to zero indentation, accumulating the defined names.
> ! (let ((start t)
> ! (accum)
> (length -1))
> ! (while (and (or start (> (current-indentation) 0))
> ! (or (null length-limit)
> ! (null (cdr accum))
> ! (< length length-limit)))
> ! (setq start nil)
> ! (python-beginning-of-block)
> ! (end-of-line)
> ! (beginning-of-defun)
> ! (when (looking-at (rx (0+ space) (or "def" "class") (1+ space)
> ! (group (1+ (or word (syntax symbol))))))
> ! (push (match-string 1) accum)
> ! (setq length (+ length 1 (length (car accum))))))
> (when accum
> (when (and length-limit (> length length-limit))
> (setcar accum ".."))
> --- 1828,1852 ----
> (save-excursion
> ;; Move up the tree of nested `class' and `def' blocks until we
> ;; get to zero indentation, accumulating the defined names.
> ! (let ((accum)
> (length -1))
> ! (catch 'done
> ! (while (or (null length-limit)
> ! (null (cdr accum))
> ! (< length length-limit))
> ! (setq start nil)
> ! (let ((started-from (point)))
> ! (python-beginning-of-block)
> ! (end-of-line)
> ! (beginning-of-defun)
> ! (when (= (point) started-from)
> ! (throw 'done nil)))
> ! (when (looking-at (rx (0+ space) (or "def" "class") (1+ space)
> ! (group (1+ (or word (syntax symbol))))))
> ! (push (match-string 1) accum)
> ! (setq length (+ length 1 (length (car accum)))))
> ! (when (= (current-indentation) 0)
> ! (throw 'done nil))))
> (when accum
> (when (and length-limit (> length length-limit))
> (setcar accum ".."))
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-08-01 0:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-21 12:49 fix infinite loop in python.el Paul Pogonyshev
2007-07-22 1:49 ` Richard Stallman
2007-07-22 16:45 ` Paul Pogonyshev
2007-07-23 4:28 ` Richard Stallman
2007-07-31 13:56 ` Paul Pogonyshev
2007-08-01 0:49 ` Vinicius Jose Latorre
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.