Skip to content

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

Merged
merged 10 commits into from
Jun 26, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Cleanup
  • Loading branch information
Rickard Holmberg committed Jun 21, 2017
commit 660b784e9be0e527d724c7947ed74a0b29cd031a
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
- Allowed passing `None` for nullable args (#460)
- Added keyword arguments based on C# syntax for calling CPython methods (#461)

### Changed
## Changed

### Fixed

Expand All @@ -22,6 +22,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
attribute (#481)
- Fixed conversion of 'float' and 'double' values (#486)
- Fixed 'clrmethod' for python 2 (#492)
- Fixed double calling of constructor when deriving from .NET class (#495)


## [2.3.0][] - 2017-03-11
Expand Down
14 changes: 0 additions & 14 deletions src/runtime/classderived.cs
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,6 @@ public static void InvokeCtor(IPythonDerivedType obj, string origCtorName, objec
obj,
args);

var disposeList = new List<PyObject>();
CLRObject self = null;
IntPtr gs = Runtime.PyGILState_Ensure();
try
Expand All @@ -821,22 +820,9 @@ public static void InvokeCtor(IPythonDerivedType obj, string origCtorName, objec
// object to be collected.
FieldInfo fi = obj.GetType().GetField("__pyobj__");
fi.SetValue(obj, self);

Runtime.XIncref(self.pyHandle);
var pyself = new PyObject(self.pyHandle);
disposeList.Add(pyself);

Runtime.XIncref(Runtime.PyNone);
var pynone = new PyObject(Runtime.PyNone);
disposeList.Add(pynone);
}
finally
{
foreach (PyObject x in disposeList)
{
x?.Dispose();
}

// Decrement the python object's reference count.
// This doesn't actually destroy the object, it just sets the reference to this object
// to be a weak reference and it will be destroyed when the C# object is destroyed.
Expand Down