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: If use element from for in while loop it will have bad iterate.
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Maks Bleo, remi.lapeyre
Priority: normal Keywords:

Created on 2020-04-17 10:17 by Maks Bleo, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
cars_av_by_spider_scr.py Maks Bleo, 2020-04-17 10:17
Messages (3)
msg366652 - (view) Author: Maks Bleo (Maks Bleo) * Date: 2020-04-17 10:17
Windows 10
Version 1909 (OS Build18363.778)
Python 3.7.7 x64

cars_av_by_spider_scr.py - py file for scrapy.
bash command to use
scrapy runspider cars_av_by_spider_scr.py -o cars_av_by_spider_scr.json > cars_av_by_spider_scr.txt 2>&1

Bad behavior in line 52. (In comment fixed version)

When while loop iterate on second step instead of using
model[0], model[1] it start use model[1][0] and model[1][1].
On third step it  crash, out of range.

But if assign value before while loop and use it in while loop everything work fine. 


It's my first bug report.
msg366654 - (view) Author: Rémi Lapeyre (remi.lapeyre) * Date: 2020-04-17 10:59
Hi Maks, when you report a bug please write a minimal example that show the bug so we don't have to read the whole application (https://stackoverflow.com/help/minimal-reproducible-example).

I think in this case that the issue is that you overrride model on line 65 `model = car[1]` hence the error on the next iteration, model has been replaced.

This bug tracker is for bugs in the Python interpreter, for help in using Python please use the python-help mailing list or a forum like StackOverflow.
msg366655 - (view) Author: Maks Bleo (Maks Bleo) * Date: 2020-04-17 11:03
I don't think that it will overwrite element from for loop. In my mind it
was a bug.

Thank you.

On Fri, Apr 17, 2020, 1:59 PM Rémi Lapeyre <report@bugs.python.org> wrote:

>
> Rémi Lapeyre <remi.lapeyre@henki.fr> added the comment:
>
> Hi Maks, when you report a bug please write a minimal example that show
> the bug so we don't have to read the whole application (
> https://stackoverflow.com/help/minimal-reproducible-example).
>
> I think in this case that the issue is that you overrride model on line 65
> `model = car[1]` hence the error on the next iteration, model has been
> replaced.
>
> This bug tracker is for bugs in the Python interpreter, for help in using
> Python please use the python-help mailing list or a forum like
> StackOverflow.
>
> ----------
> nosy: +remi.lapeyre
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue40310>
> _______________________________________
>
History
Date User Action Args
2022-04-11 14:59:29adminsetgithub: 84490
2020-04-17 11:06:33Maks Bleosetstatus: open -> closed
resolution: not a bug
stage: resolved
2020-04-17 11:03:13Maks Bleosetmessages: + msg366655
2020-04-17 10:59:25remi.lapeyresetnosy: + remi.lapeyre
messages: + msg366654
2020-04-17 10:17:23Maks Bleocreate