From eb9094287296c8b555bb5d579a0261022eb0a583 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Sat, 2 Jan 2021 22:45:06 +0100 Subject: [PATCH] Work around __weakref__ + __slots__ + Generics bug on Python 3.6 See bug https://bugs.python.org/issue41451 --- psycopg3/psycopg3/cursor.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/psycopg3/psycopg3/cursor.py b/psycopg3/psycopg3/cursor.py index d03428b20..0c0d092fa 100644 --- a/psycopg3/psycopg3/cursor.py +++ b/psycopg3/psycopg3/cursor.py @@ -45,11 +45,15 @@ else: class BaseCursor(Generic[ConnectionType]): - __slots__ = """ - _conn format _adapters arraysize _closed _results _pgresult _pos - _iresult _rowcount _query _params _transformer - __weakref__ - """.split() + # Slots with __weakref__ and generic bases don't work on Py 3.6 + # https://bugs.python.org/issue41451 + if sys.version_info >= (3, 7): + __slots__ = """ + _conn format _adapters arraysize _closed _results _pgresult _pos + _iresult _rowcount _query _params _transformer + __weakref__ + """.split() + ExecStatus = pq.ExecStatus _transformer: "Transformer" -- 2.47.2