scons: RuntimeError: dictionary changed size during iteration
Scons 4.0.1 on Gentoo Linux. I didn’t get and answer on Discord, so posting here
File "/usr/lib/python3.8/site-packages/SCons/Environment.py", line 1407, in Clone
clone._dict = semi_deepcopy_dict(self._dict, ['BUILDERS'])
File "/usr/lib/python3.8/site-packages/SCons/Util.py", line 539, in semi_deepcopy_dict
for key, val in x.items():
RuntimeError: dictionary changed size during iteration:
My company uses Scons for a huge project, so it’s sometimes hard to say what’s going on or how Scons was invoked. But quite likely the code above was executed in a thread and I don’t know if it’s eligible.
I believe the easiest fix is to get a list of keys and not items iterator.
something like this probably
def semi_deepcopy_dict(x, exclude = [] ):
copy = {}
for key in list(x.keys()):
# The regular Python copy.deepcopy() also deepcopies the key,
# as follows:
#
# copy[semi_deepcopy(key)] = semi_deepcopy(val)
#
# Doesn't seem like we need to, but we'll comment it just in case.
if key not in exclude:
copy[key] = semi_deepcopy(x[key])
return copy
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 15 (4 by maintainers)
sure. I’ll make a reproducer. Unfortunately it won’t be soon.