Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fixed reference counting for exception objects in Py.With#1062

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
filmor merged 1 commit intopythonnet:masterfromlosttech:bugs/1050
Feb 26, 2020
Merged
Show file tree
Hide file tree
Changes fromall commits
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
11 changes: 9 additions & 2 deletionssrc/runtime/Util.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@

namespace Python.Runtime
{
internal class Util
internalstaticclass Util
{
internal static Int64 ReadCLong(IntPtr tp, int offset)
{
Expand All@@ -29,5 +29,12 @@ internal static void WriteCLong(IntPtr type, int offset, Int64 flags)
Marshal.WriteInt64(type, offset, flags);
}
}

/// <summary>
/// Null-coalesce: if <paramref name="primary"/> parameter is not
/// <see cref="IntPtr.Zero"/>, return it. Otherwise return <paramref name="fallback"/>.
/// </summary>
internal static IntPtr Coalesce(this IntPtr primary, IntPtr fallback)
=> primary == IntPtr.Zero ? fallback : primary;
}
}
}
9 changes: 6 additions & 3 deletionssrc/runtime/pythonengine.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -758,11 +758,14 @@ public static void With(PyObject obj, Action<dynamic> Body)
catch (PythonException e)
{
ex = e;
type = ex.PyType;
val = ex.PyValue;
traceBack = ex.PyTB;
type = ex.PyType.Coalesce(type);
val = ex.PyValue.Coalesce(val);
traceBack = ex.PyTB.Coalesce(traceBack);
}

Runtime.XIncref(type);
Runtime.XIncref(val);
Runtime.XIncref(traceBack);
var exitResult = obj.InvokeMethod("__exit__", new PyObject(type), new PyObject(val), new PyObject(traceBack));

if (ex != null && !exitResult.IsTrue()) throw ex;
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp