[issue38372] Undefined behavior when changing dict while iterating it

2019-10-04 Thread Beatris Boneva
Beatris Boneva added the comment: Now I see it is duplicate of https://bugs.python.org/issue19332. Closing it. -- stage: -> resolved status: open -> closed ___ Python tracker ___

[issue38372] Undefined behavior when changing dict while iterating it

2019-10-04 Thread Беатрис Бонева
New submission from Беатрис Бонева : When changing a dict while iterating through it by removing one key and inserting other which is calculated based on the old one, the dict is changed unexpectedly. The following function: ``` def test(d: dict): for i in d: d[i+1] = d.pop(i)