[issue5042] Structure sub-subclass does not initialize with base class positional arguments
Jason R. Coombs
report at bugs.python.org
Thu Sep 17 22:09:07 CEST 2009
Jason R. Coombs <jaraco at jaraco.com> added the comment:
That was easier than I thought. The generated code is _ugly_ but it did
seem to be able to generate it.
I created init.pyx
{{{
class X(object):
def __init__(self, *args, **kw):
"""This is how the Structure's __init__method SHOULD be"""
if args:
names = []
for tp in self.__class__.mro()[2::-1]:
for n, _ in tp._fields_:
names.append(n)
for n, v in zip(names, args):
setattr(self, n, v)
for n, v in kw.iteritems():
setattr(self, n, v)
}}}
Then, ran cython init.pyx and got the attached file.
Is that any help?
----------
Added file: http://bugs.python.org/file14920/init.c
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5042>
_______________________________________
More information about the Python-bugs-list
mailing list