Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
__conform__ shoud take the precedence over superclass adaptation #456
If an object declares itself conform, its rule should be applied. Currently (psycopg 2.6.2) the adapter first checks if a superclass is conform, then tries to use its rule. This makes impossible e.g. to just implement
In : import psycopg2.extensions as ext In : class foo(tuple): ...: def __conform__(self, proto): ...: return self ...: def getquoted(self): ...: return 'bar' ...: In : ext.adapt(foo((1,2,3))).getquoted() Out: '(1, 2, 3)'
The result should have been the same of:
In : class foo2(object): def __conform__(self, proto): return self def getquoted(self): return 'bar' ...: In : ext.adapt(foo2()).getquoted() Out: 'bar'
I'd like to fix it. There is a slight possibility to break some code... but I guess only for people who wrote their own
Shall we fix it in psycopg3 or in 2.7?