From f8d73a9a0d72e3229edd2c08411c3ca434fd6f0f Mon Sep 17 00:00:00 2001 From: Stefan Engert Date: Tue, 22 Sep 2020 13:41:40 +0200 Subject: [PATCH] Fix RuntimeError fixes RuntimeError: dictionary changed size during iteration object is now changed after and not while iterating over it --- sphinxcontrib/domaintools/__init__.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sphinxcontrib/domaintools/__init__.py b/sphinxcontrib/domaintools/__init__.py index f39ed27..6ad7cb5 100644 --- a/sphinxcontrib/domaintools/__init__.py +++ b/sphinxcontrib/domaintools/__init__.py @@ -104,11 +104,14 @@ class CustomDomain(Domain): } def clear_doc(self, docname): - if 'objects' in self.data: - - for key, (fn, _) in self.data['objects'].items(): - if fn == docname: - del self.data['objects'][key] + clr_keys = [] + if 'objects' in self.data: + for key, (fn, _) in self.data['objects'].items(): + if fn == docname: + clr_keys.append(key) + + for key in clr_keys: + del self.data['objects'][key] def resolve_xref(self, env, fromdocname, builder, typ, target, node, contnode):