You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Constructor executed twice when overriding constructor in System.Object. #495
Furthermore, if you add arguments to the constructor, the arguments are only passed the second time.
classX(System.Object):__namespace__= "PyTest"
def __init__(self,*args):print("Running X constructor, args = {0}".format(args))x=X(1,2)
produces the output
Running X constructor, args = ()
Running X constructor, args = (1, 2)
It seems that the first invocation is from the call in Python.Runtime.MetaType.tp_call to tp_new, whereas the second invocation is from the call to py__init__ using Runtime.PyObject_Call.
Is the error that somehow the call to tp_new also ends up calling __init__?
/// Metatype __call__ implementation. This is needed to ensure correct
/// initialization (__init__ support), because the tp_call we inherit
/// from PyType_Type won't call __init__ for metatypes it doesn't know.
Activity
rickardraysearch commentedon Jun 15, 2017
Furthermore, if you add arguments to the constructor, the arguments are only passed the second time.
produces the output
It seems that the first invocation is from the call in
Python.Runtime.MetaType.tp_calltotp_new, whereas the second invocation is from the call topy__init__usingRuntime.PyObject_Call.Is the error that somehow the call to
tp_newalso ends up calling__init__?filmor commentedon Jun 16, 2017
Hmm, the comment says
Maybe this changed in Python? I'll have a look.
Drop tp_call implementation from metatype.
Drop tp_call implementation from metatype.
Another shot at #495 (#503)
filmor commentedon Jul 11, 2017
Fixed by #503.
Another shot at pythonnet#495 (pythonnet#503)