From: Mike Bayer Date: Thu, 15 Jul 2021 14:36:53 +0000 (-0400) Subject: apply list() around weakkeydictionary iteration X-Git-Tag: rel_1_4_22~8^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f3c4735c0bef6325e977876e12fc476da363ec3c;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git apply list() around weakkeydictionary iteration Fixed an issue where clearing of mappers during things like test suite teardowns could cause a "dictionary changed size" warning during garbage collection, due to iteration of a weak-referencing dictionary. A ``list()`` has been applied to prevent concurrent GC from affecting this operation. Fixes: #6771 Change-Id: I3e1d67e978b2726a282d8b327457f2d4b239a0c6 --- diff --git a/doc/build/changelog/unreleased_14/6771.rst b/doc/build/changelog/unreleased_14/6771.rst new file mode 100644 index 0000000000..811ee7d825 --- /dev/null +++ b/doc/build/changelog/unreleased_14/6771.rst @@ -0,0 +1,8 @@ +.. change:: + :tags: orm, bug + :tickets: 6771 + + Fixed an issue where clearing of mappers during things like test suite + teardowns could cause a "dictionary changed size" warning during garbage + collection, due to iteration of a weak-referencing dictionary. A ``list()`` + has been applied to prevent concurrent GC from affecting this operation. diff --git a/lib/sqlalchemy/orm/decl_api.py b/lib/sqlalchemy/orm/decl_api.py index 54e927ee47..23b89a5434 100644 --- a/lib/sqlalchemy/orm/decl_api.py +++ b/lib/sqlalchemy/orm/decl_api.py @@ -624,14 +624,14 @@ class registry(object): return itertools.chain( ( manager.mapper - for manager in self._managers + for manager in list(self._managers) if manager.is_mapped and not manager.mapper.configured and manager.mapper._ready_for_configure ), ( npm - for npm in self._non_primary_mappers + for npm in list(self._non_primary_mappers) if not npm.configured and npm._ready_for_configure ), )