1

This is a part of traceback I've got. And I have no idea how is it possible.

There is no multi-threading (I think). But even if there is a thread which is changing gloabls() is it possible to change globals() during list creation? I thought list() call is protected with GIL, isn't it?

I reproduced it twice, but now I can't reproduce it.

Do you have any ideas how is it possible?

Source code: https://github.com/python/cpython/blob/3.5/Lib/lib2to3/pgen2/token.py#L73

Python 3.5.2, CentOS Linux release 7.4.1708

from past.builtins import basestring
  File "/home/user/app/lib64/python3.5/site-packages/past/__init__.py", line 88, in <module>
from past.translation import install_hooks as autotranslate
  File "/home/user/app/lib64/python3.5/site-packages/past/translation/__init__.py", line 41, in <module>
from lib2to3.pgen2.parse import ParseError
  File "/usr/lib64/python3.5/lib2to3/pgen2/parse.py", line 14, in <module>
from . import token
  File "/usr/lib64/python3.5/lib2to3/pgen2/token.py", line 73, in <module>
for _name, _value in list(globals().items()):
RuntimeError: dictionary changed size during iteration
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
  • 2
    Ideally, your question should contain the problematic code, pared down to a [mcve]. A link for background is welcome, but your question should stand on its own even if the link disappears, or, as the case may be, you fix the code behind the link once you understand what's wrong. – tripleee Apr 18 '18 at 15:33
  • Interesting, but what code exactly are you running and how do you launch it? If you can't reproduce it, then I'm not sure how we can – Chris_Rands Apr 18 '18 at 15:33
  • Note if this *is* a reproducible bug in Python it should probably be a Python bug report not an SO question. – jonrsharpe Apr 18 '18 at 15:43
  • 2
    A call to `list` is not protected with GIL, no. GIL operates at opcode atomicity, and one list call is a *much* higher level. – wim Apr 18 '18 at 15:43

0 Answers0