Bugs item #783240, was opened at 2003-08-05 05:11
Message generated for change (Comment added) made by mark_byers
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=581349&aid=783240&group_id=86916

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Skip Montanaro (montanaro)
Assigned to: Nobody/Anonymous (nobody)
Summary: python-mode loops on if/else

Initial Comment:
(migrating from python project)

Original submission:

Here's how to reproduce.  Create a .py file in XEmacs 
 containing this text: 
  
 x = (if 1: 2 
  ____else: 3) 
  
 (except that the ____ really means four spaces). 
  
 Now position your cursor somewhere inside those 4 
 spaces, and hit TAB. XEmacs freezes until you hit 
^G.

Followup comments:

Date: 2003-07-31 22:41
Sender: montanaro
Logged In: YES 
user_id=44345

The code gets into an infloop in py-outdent-p.  The 
loop looks
odd to me:

  (while (or (looking-at py-blank-or-comment-re)
                (bobp))
     (backward-to-indentation 1))

If you were at (bobp), why would you want to try to 
move back
a line?

----------------------------------------------------------------------

Comment By: Mark Byers (mark_byers)
Date: 2005-02-20 22:28

Message:
Logged In: YES 
user_id=1223583

Here is a patch file. I wasn't sure how to attach it as a
file, so here it is in plain text. It seems that the 'short
circuit infloop on illegal construct' line is no longer
needed so I have removed it.

--- python-mode/python-mode.el  2005-02-20 14:23:58.000000000
+0100
+++ python-mode/python-mode.el.new      2005-02-20
14:29:05.319602112 +0100
@@ -1239,13 +1239,11 @@
   (save-excursion
     (and (progn (back-to-indentation)
                (looking-at py-outdent-re))
-        ;; short circuit infloop on illegal construct
-        (not (bobp))
         (progn (forward-line -1)
                (py-goto-initial-line)
                (back-to-indentation)
-               (while (or (looking-at py-blank-or-comment-re)
-                          (bobp))
+               (while (and (looking-at py-blank-or-comment-re)
+                          (not (bobp)))
                  (backward-to-indentation 1))
                (not (looking-at py-no-outdent-re)))
         )))


----------------------------------------------------------------------

Comment By: Mark Byers (mark_byers)
Date: 2005-02-20 14:46

Message:
Logged In: YES 
user_id=1223583

I can confirm this bug.

The following two line file also causes an infinite loop:

a
else:

When the colon is typed, the inifinite loop is triggered.

I think the following change fixes the problem: 

-               (while (or (looking-at py-blank-or-comment-re)
-                          (bobp))
+               (while (and (looking-at py-blank-or-comment-re)
+                          (not (bobp)))
                  (backward-to-indentation 1))


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=581349&aid=783240&group_id=86916
_______________________________________________
Python-mode mailing list
Python-mode@python.org
http://mail.python.org/mailman/listinfo/python-mode

Reply via email to