]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Use a copy of `self.contents` in this list comprehension.
authorYilei Yang <yileiyang@google.com>
Tue, 19 Dec 2023 21:15:52 +0000 (13:15 -0800)
committerYilei Yang <yileiyang@google.com>
Tue, 19 Dec 2023 21:15:52 +0000 (13:15 -0800)
Fixes #10782.

lib/sqlalchemy/orm/clsregistry.py

index 4f4dab895e416a5f9e8f484cffb8867f0012240a..b78f4bdeea615085865e020736d22e782b82b151 100644 (file)
@@ -239,10 +239,10 @@ class _MultipleClassMarker(ClsRegistryToken):
     def add_item(self, item: Type[Any]) -> None:
         # protect against class registration race condition against
         # asynchronous garbage collection calling _remove_item,
-        # [ticket:3208]
+        # [ticket:3208] and [ticket:10782]
         modules = {
             cls.__module__
-            for cls in [ref() for ref in self.contents]
+            for cls in [ref() for ref in self.contents.copy()]
             if cls is not None
         }
         if item.__module__ in modules: