]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
fix: add assertion to ensure 'existing' is not None
authorShamil <ashm.tech@proton.me>
Fri, 18 Apr 2025 20:27:10 +0000 (23:27 +0300)
committerShamil <ashm.tech@proton.me>
Fri, 18 Apr 2025 20:27:10 +0000 (23:27 +0300)
Prevented potential issues by asserting that 'existing' is never None.
Added to enforce invariant and improve debugging in edge cases.

lib/sqlalchemy/orm/identity.py

index f5959cfe1545dcdf226b4738d19eb641483a85cb..7649cab7cebc5db558282fffeacfc172d5a8c6c6 100644 (file)
@@ -167,6 +167,7 @@ class _WeakInstanceDict(IdentityMap):
         else:
             if existing is state:
                 return None
+            assert existing is not None
             self._manage_removed_state(existing)
 
         self._dict[state.key] = state