[issue16571] Iterating over inconsistently-indented code block causes execution of code only on last iteration of loop

2012-11-28 Thread Brian Berard

New submission from Brian Berard:

When a loop (for loop in this case) contains multiple lines of code, if the 
lines are inconsistently indented, the for loop will only execute those lines 
on the final pass through the loop with no type of warning regarding 
indentation error. 

Ex. 

for i in range(0,10):
print I will print on every iteration: %d % i  # TAB indented
print I will only print on the final iteration: %d % i # 4 spaces

--
components: Interpreter Core
files: python_test.py
messages: 176551
nosy: dimitriprosser
priority: normal
severity: normal
status: open
title: Iterating over inconsistently-indented code block causes execution of 
code only on last iteration of loop
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file28149/python_test.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16571
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16571] Iterating over inconsistently-indented code block causes execution of code only on last iteration of loop

2012-11-28 Thread Brian Berard

Changes by Brian Berard dimitripros...@gmail.com:


--
type: behavior - enhancement

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16571
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16571] Iterating over inconsistently-indented code block causes execution of code only on last iteration of loop

2012-11-28 Thread Mark Dickinson

Mark Dickinson added the comment:

This is expected behaviour for Python 2.x:  Python interprets every TAB 
character as advancing to the next multiple-of-8 column, regardless of how your 
editor sees it.  It would be too disruptive to change this behaviour in Python 
2.x.

It's already fixed in Python 3: there it's a syntax error to mix tabs and 
spaces in this way.  Python 2.7 gives a warning if you run with the '-3' flag.

--
nosy: +mark.dickinson
resolution:  - wont fix
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16571
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16571] Iterating over inconsistently-indented code block causes execution of code only on last iteration of loop

2012-11-28 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
stage:  - committed/rejected

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16571
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16571] Iterating over inconsistently-indented code block causes execution of code only on last iteration of loop

2012-11-28 Thread Ned Batchelder

Ned Batchelder added the comment:

@Brian:  Your code doesn't run in Python 2.7 as you've shown it, it produces an 
IndentationError.  If your code is actually different, and does run, try 
running it with the -tt flag on Python, which will warn about inconsistent 
indentation.

--
nosy: +nedbat

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16571
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16571] Iterating over inconsistently-indented code block causes execution of code only on last iteration of loop

2012-11-28 Thread Brian Berard

Brian Berard added the comment:

@nedbat I'm able to run that code as is and receive no such error. With the -tt 
option, I do receive an indentation error. I will keep that in mind.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16571
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com