From: Daniele Varrazzo Date: Fri, 23 Jul 2021 16:45:11 +0000 (+0200) Subject: Don't copy the types map from context to recursive dumpers X-Git-Tag: 3.0.dev2~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cfa3fa212d1b15f1803e7894618cfa07ce7b73ed;p=thirdparty%2Fpsycopg.git Don't copy the types map from context to recursive dumpers It can be accessed from the object's transformer. --- diff --git a/psycopg/psycopg/types/array.py b/psycopg/psycopg/types/array.py index 740c803c9..1b82e76ba 100644 --- a/psycopg/psycopg/types/array.py +++ b/psycopg/psycopg/types/array.py @@ -36,7 +36,6 @@ class BaseListDumper(RecursiveDumper): def __init__(self, cls: type, context: Optional[AdaptContext] = None): super().__init__(cls, context) self.sub_dumper: Optional[Dumper] = None - self._types = context.adapters.types if context else postgres.types def get_key(self, obj: List[Any], format: PyFormat) -> DumperKey: item = self._find_list_element(obj) @@ -106,7 +105,7 @@ class BaseListDumper(RecursiveDumper): """ oid = 0 if base_oid: - info = self._types.get(base_oid) + info = self._tx.adapters.types.get(base_oid) if info: oid = info.array_oid diff --git a/psycopg/psycopg/types/range.py b/psycopg/psycopg/types/range.py index 561f5f466..b343fd644 100644 --- a/psycopg/psycopg/types/range.py +++ b/psycopg/psycopg/types/range.py @@ -256,7 +256,6 @@ class BaseRangeDumper(RecursiveDumper): def __init__(self, cls: type, context: Optional[AdaptContext] = None): super().__init__(cls, context) self.sub_dumper: Optional[Dumper] = None - self._types = context.adapters.types if context else postgres.types self._adapt_format = PyFormat.from_pq(self.format) def get_key(self, obj: Range[Any], format: PyFormat) -> DumperKey: @@ -314,7 +313,7 @@ class BaseRangeDumper(RecursiveDumper): Raise InterfaceError if not found. """ - info = self._types.get_range(sub_oid) + info = self._tx.adapters.types.get_range(sub_oid) return info.oid if info else INVALID_OID