Bug#994911: error modifying deb822 object while iterating
Jelmer Vernooij
jelmer at debian.org
Thu Oct 14 20:17:47 BST 2021
On Sun, Oct 10, 2021 at 08:41:55AM +0200, Niels Thykier wrote:
> On Thu, 23 Sep 2021 00:43:50 +0000 Jelmer Vernooij <jelmer at debian.org>
> wrote:
> > Package: python3-debian
> > Version: 0.1.41
> > Severity: normal
> >
> > Modifying a deb822 file while iterating over it results in a RuntimeError:
> >
> > ...
> > File "/home/jelmer/src/debian-janitor/python-debian/lib/debian/_deb822_repro/parsing.py", line 2208, in iter_keys
> > yield from self._kvpair_elements
> > RuntimeError: dictionary keys changed during iteration
> >
> > (This doesn't happen with the default deb822 implementation)
> >
> > [...]
>
>
> Hi,
>
> Can you provide the code snippet that triggers this bug?
>
> As I understand it, this is "normal" for a dict depending on the exact
> usage, which is why I would like to see what you were doing when you
> triggered the bug. :)
>
> Example with dict:
>
> >>>> d = {'a': 1, 'b': 2}
> >>>> for e in d:
> > ... if d[e] == 2:
> > ... d['z'] = 1
> > ...
> > Traceback (most recent call last):
> > File "<stdin>", line 1, in <module>
> > RuntimeError: dictionary changed size during iteration
> >>>> for e in d:
> > ... d[e] = 2
> > ...
> >>>>
Yep, this is standard behaviour with a dict - so I wouldn't be surprised if
this was happening generally, but the default deb822 doesn't exhibit
this so it makes migrating a bit harder.
Unfortunately I've lost track of the run in the janitor that
showed this issue so we'll just have to re-enable and see
if it's fixed now.
Jelmer
More information about the pkg-python-debian-maint
mailing list