-
Notifications
You must be signed in to change notification settings - Fork 749
Another shot at #495 #503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Another shot at #495 #503
Conversation
@rickardraysearch, thanks! @vmuriart, @tonyroberts, @tiran, @ArvidJB and @brianlloyd, please review this. |
Codecov Report
@@ Coverage Diff @@
## master #503 +/- ##
==========================================
+ Coverage 76.41% 77.21% +0.79%
==========================================
Files 64 64
Lines 5572 5534 -38
Branches 895 887 -8
==========================================
+ Hits 4258 4273 +15
+ Misses 1020 975 -45
+ Partials 294 286 -8
Continue to review full report at Codecov.
|
src/tests/test_subclass.py
Outdated
assert calls[0][0] == (1,2,3) | ||
assert calls[0][1] == {"foo":"bar"} | ||
|
||
def test_clr_subclass_without_init_args(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please rename test_clr_subclass_init_without_args
IntPtr type = Runtime.PyObject_TYPE(obj); | ||
IntPtr init = Runtime._PyType_Lookup(type, py__init__); | ||
Runtime.XDecref(py__init__); | ||
var init = Runtime.PyObject_GetAttrString(obj, "__init__"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are leaking this reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. Should be fixed now.
Could you explain how and why this works? /edit: Never mind, got it :) |
I believe that what's happening is that Since the class' When constructing python objects from e.g. C#, the |
4fe93c4
to
f72c8cc
Compare
From the commit history, it looks as if the call was added to invoke By the way, there are two tests in /edit: I reenabled them, and they worked on both Travis and Appveyor, at least this time. |
Thank you very much for your contribution. We'll have to see, whether this breaks compatibility for anyone, we probably should put a note into the changelog, documenting this change of behaviour. |
Yes, it definitely makes sense to put a good explanation in the changelog. Also, could we have a discussion on how to bring back that functionality and exposing additional arguments to the managed constructors? Maybe a new issue is the best place for that. Many thanks for merging this, by the way! It really makes a big difference for my chances of getting us to use pythonnet here. |
Feel free to open one :) |
* Add tests of subclassing with __namespace__ * Remove __init__ call from ClassDerived.InvokeCtor * Trying out __init__ * Cleanup * Add tests constructing python type from CLR and calling __init__ * Revert borked changelog update * Don't leak init reference * Rename tests * Remove unused internal Runtime.GetBoundArgTuple * Reenable skipped tests in test_subclass.py
What does this implement/fix? Explain your changes.
Remove the extraneous call to
__init__
fromClassDerived.InvokeCtor
.Does this close any currently open issues?
#495
Any other comments?
This is a different shot at fixing #495 . @filmor has one at #496 but it fails a couple of tests. This one might have some bugs wrt
XDecref
inMetaType.tp_call
still.Checklist
Check all those that are applicable and complete.
AUTHORS
CHANGELOG