Re: [Sqlalchemy-tickets] [sqlalchemy] #2732: bug in get_cls_kwargs, affects sybase dialect
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2013-05-22 22:11:53
|
#2732: bug in get_cls_kwargs, affects sybase dialect
---------------------------+----------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: new
Priority: highest | Milestone: 0.8.xx
Component: engine | Severity: minor - half an hour
Resolution: | Keywords:
Progress State: in queue |
---------------------------+----------------------------------
Comment (by zzzeek):
work in progress
{{{
#!diff
diff -r e57b8df1f95e lib/sqlalchemy/util/langhelpers.py
--- a/lib/sqlalchemy/util/langhelpers.py Wed May 15 15:46:29 2013
-0400
+++ b/lib/sqlalchemy/util/langhelpers.py Wed May 22 18:11:31 2013
-0400
@@ -163,9 +163,11 @@
"""
- for c in cls.__mro__:
+ mro = list(cls.__mro__)
+ while mro:
+ c = mro.pop(0)
if '__init__' in c.__dict__:
- stack = set([c])
+ stack = set([c]) # for very liberal, say set([cls]) here
break
else:
return []
@@ -187,6 +189,8 @@
args.update(names)
if has_kw:
stack.update(class_.__bases__)
+ if mro:
+ stack.add(mro.pop(0))
args.discard('self')
return args
diff -r e57b8df1f95e test/base/test_utils.py
--- a/test/base/test_utils.py Wed May 15 15:46:29 2013 -0400
+++ b/test/base/test_utils.py Wed May 22 18:11:31 2013 -0400
@@ -1084,6 +1084,10 @@
def __init__(self, b1, **kw):
pass
+ class B2(B):
+ def __init__(self, b2):
+ pass
+
class AB(A, B):
def __init__(self, ab):
pass
@@ -1101,15 +1105,24 @@
class CBA(B, A):
pass
+ class CB1A1(B1, A1):
+ pass
+
class CAB1(A, B1):
pass
class CB1A(B1, A):
pass
+ class CB2A(B2, A):
+ pass
+
class D(object):
pass
+ class E(B, A):
+ pass
+
def test(cls, *expected):
eq_(set(util.get_cls_kwargs(cls)), set(expected))
@@ -1122,10 +1135,13 @@
test(BA, 'ba', 'b', 'a')
test(BA1, 'ba', 'b', 'a')
test(CAB, 'a')
- test(CBA, 'b')
+ test(CBA, 'b', 'a')
test(CAB1, 'a')
- test(CB1A, 'b1', 'b')
+ test(CB1A, 'b1', 'b', 'a')
+ test(CB2A, 'b2')
+ test(CB1A1, "a1", "b1", "b")
test(D)
+ test(E, "a", "b")
def test_get_func_kwargs(self):
}}}
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2732#comment:2>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|