From: Daniele Varrazzo Date: Fri, 16 Jul 2021 01:41:06 +0000 (+0200) Subject: Fix types registry shallow copy X-Git-Tag: 3.0.dev1~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=856526b5d6b3dcf141e3aaf8f2091acae2a63d9f;p=thirdparty%2Fpsycopg.git Fix types registry shallow copy Mark the template as dirty, so that if it's changed the registries that were cloned for it will remain unchanged. --- diff --git a/psycopg/psycopg/_typeinfo.py b/psycopg/psycopg/_typeinfo.py index f9d2d5b76..437d1fb81 100644 --- a/psycopg/psycopg/_typeinfo.py +++ b/psycopg/psycopg/_typeinfo.py @@ -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()