[Python-mode] [ python-mode-Bugs-783240 ] python-mode loops on if/else

SourceForge.net noreply at sourceforge.net
Sun Feb 20 14:46:42 CET 2005


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 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


More information about the Python-mode mailing list