This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: 'for' loop not automatically breaking (index error on line of loop header)
Type: behavior Stage: resolved
Components: Windows Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Justin McNiel, brett.cannon, ezio.melotti, josh.r, paul.moore, steve.dower, steven.daprano, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2017-02-10 02:47 by Justin McNiel, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
pythonError.png Justin McNiel, 2017-02-10 02:47 Image of the specific error
Messages (5)
msg287473 - (view) Author: Justin McNiel (Justin McNiel) Date: 2017-02-10 02:47
All for loops are refusing to break (Python 2.7.13) on win32
      - only on execution of '.py' file
an example would be:"
for x in range(5): #Line 1 of main.py
    print x        #Line 2 of main.py
"
and the resulting error would be:"
    File "pathToFile\main.py", line 1, in <module>
        for x in range(5):
IndexError: array index out of range
"
I also have 32-bit python 3.6 installed, but the default for opening '.py' files is python 2.7
This error happens on custom made generators too, but never in the interactive shell.
msg287474 - (view) Author: Josh Rosenberg (josh.r) * (Python triager) Date: 2017-02-10 03:05
You're going to need to actually provide the source file here. This makes no sense as is.
msg287510 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2017-02-10 10:53
I agree with Josh: the exception you are giving doesn't seem possible with the code snippet shown. Please COPY AND PASTE (not a screen shot) the text of the entire traceback, starting with the line "Traceback..."

I suspect that you may have shadowed the built-in range or len object with some custom object, but I could be completely wrong. But without more information, we cannot tell what is going on.

It would be really useful if you could provide a minimal (short as possible) script that reproduces the problem. And please confirm that you can reproduce the problem in the regular CPython interpreter, without using any third-party IDEs.
msg287581 - (view) Author: Justin McNiel (Justin McNiel) Date: 2017-02-11 00:47
While restarting didn't fix it, waiting for the next morning did, so I am
afraid that that isn't possible, also, I have made tremendous changes to my
code since then, but I would by happy to send you any bit of my code that
you would like, it cold also be an issue with my computer, our IT
department is very work heavy and doesn't always install the operating
system properly (ie. not installing the driver for the touchpad)

On Feb 10, 2017 4:53 AM, "Steven D'Aprano" <report@bugs.python.org> wrote:

>
> Steven D'Aprano added the comment:
>
> I agree with Josh: the exception you are giving doesn't seem possible with
> the code snippet shown. Please COPY AND PASTE (not a screen shot) the text
> of the entire traceback, starting with the line "Traceback..."
>
> I suspect that you may have shadowed the built-in range or len object with
> some custom object, but I could be completely wrong. But without more
> information, we cannot tell what is going on.
>
> It would be really useful if you could provide a minimal (short as
> possible) script that reproduces the problem. And please confirm that you
> can reproduce the problem in the regular CPython interpreter, without using
> any third-party IDEs.
>
> ----------
> nosy: +steven.daprano
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue29518>
> _______________________________________
>
msg287718 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2017-02-13 18:20
Since Justin can't provide the original email, it could have been his setup, and the chances that range() is broken on Python 2.7 is extremely small, I'm closing this as not a bug.
History
Date User Action Args
2022-04-11 14:58:43adminsetgithub: 73704
2017-02-13 18:20:49brett.cannonsetstatus: open -> closed

nosy: + brett.cannon
messages: + msg287718

resolution: not a bug
stage: resolved
2017-02-11 00:47:38Justin McNielsetmessages: + msg287581
2017-02-10 19:31:36ezio.melottisetnosy: + ezio.melotti
2017-02-10 10:53:03steven.dapranosetnosy: + steven.daprano
messages: + msg287510
2017-02-10 03:05:07josh.rsetnosy: + josh.r
messages: + msg287474
2017-02-10 02:47:38Justin McNielcreate