Skip to content
Merged
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
do not dispose object, that might have been just decoded succesfully,…
… as the decoded object might store a reference to the original PyObject
  • Loading branch information
lostmsu committed Feb 23, 2020
commit 399ae545c9c6a4ab0a0f1713e41eb1c41c889ca4
13 changes: 8 additions & 5 deletions src/runtime/converterextensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,16 @@ static Converter.TryConvertFromPythonDelegate GetDecoder(IntPtr sourceType, Type

bool TryDecode(IntPtr pyHandle, out object result)
{
using (var pyObj = new PyObject(Runtime.SelfIncRef(pyHandle)))
var pyObj = new PyObject(Runtime.SelfIncRef(pyHandle));
var @params = new object[] { pyObj, null };
bool success = (bool)decode.Invoke(decoder, @params);
if (!success)
{
var @params = new object[] { pyObj, null };
bool success = (bool)decode.Invoke(decoder, @params);
result = @params[1];
return success;
pyObj.Dispose();
}

result = @params[1];
return success;
}

return TryDecode;
Expand Down