On 5/30/2018 4:48 AM, Frank Millman wrote:
Hi all
I want to work backwards to solve this problem, so I have to explain it
forwards to put you in the picture.
I have an Ordered Dictionary. Under certain circumstances I am getting
this error -
RuntimeError: OrderedDict mutated during iteration
This should mean that the value associated with a key was sometimes changed.
I can see why this is happening, and I am pretty sure I can fix it by
making a copy to iterate over.
However, the error seems to be intermittent - there are times when it
should fail, but does not - so I want to investigate further.
I tried to reduce it to a simple example. I succeeded, but there are two
problems -
1. It always fails, so I have not reproduced the intermittent nature yet.
2. It gives a different error -
RuntimeError: dictionary changed size during iteration
This should mean that a new key-value pair was always added or removed.
So my first question is, what is the difference between the two error
messages? I am using an OrderedDict for my test as well, so the
difference is not caused by using a normal dictionary.
I am using Python 3.6.0.
--
Terry Jan Reedy
--
https://mail.python.org/mailman/listinfo/python-list