]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Fix types registry shallow copy
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 16 Jul 2021 01:41:06 +0000 (03:41 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 16 Jul 2021 23:39:59 +0000 (01:39 +0200)
Mark the template as dirty, so that if it's changed the registries that
were cloned for it will remain unchanged.

psycopg/psycopg/_typeinfo.py

index f9d2d5b763e1d5141d98980f7ceb337334d3ed77..437d1fb81994a789977dd55989843ddc5c606eb4 100644 (file)
@@ -232,15 +232,13 @@ class TypesRegistry:
         self._by_range_subtype: Dict[int, TypeInfo]
 
         # Make a shallow copy: it will become a proper copy if the registry
-        # is edited (note the BUG: a child will get shallow-copied, but changing
-        # the parent will change children who weren't copied yet. It can be
-        # probably fixed by setting _own_state to False on the parent on copy,
-        # but needs testing and for the moment I'll leave it there TODO).
+        # is edited.
         if template:
             self._by_oid = template._by_oid
             self._by_name = template._by_name
             self._by_range_subtype = template._by_range_subtype
             self._own_state = False
+            template._own_state = False
         else:
             self.clear()