FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix exception pickling by filmor · Pull Request #286 · pythonnet/pythonnet · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .cs  (8) .py  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
3 changes: 3 additions & 0 deletions src/runtime/clrobject.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ internal CLRObject(Object ob, IntPtr tp) : base()
this.pyHandle = py;
this.gcHandle = gc;
inst = ob;

// Fix the BaseException args slot if wrapping a CLR exception
Exceptions.SetArgs(py);
}


Expand Down
45 changes: 1 addition & 44 deletions src/runtime/converter.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,7 @@ internal static IntPtr ToPython(Object value, Type type)
switch (tc)
{
case TypeCode.Object:
result = CLRObject.GetInstHandle(value, type);

// XXX - hack to make sure we convert new-style class based
// managed exception instances to wrappers ;(
if (Runtime.wrap_exceptions)
{
Exception e = value as Exception;
if (e != null)
{
return Exceptions.GetExceptionInstanceWrapper(result);
}
}

return result;
return CLRObject.GetInstHandle(value, type);

case TypeCode.String:
return Runtime.PyUnicode_FromString((string)value);
Expand Down Expand Up @@ -283,36 +270,6 @@ internal static bool ToManagedValue(IntPtr value, Type obType,
ManagedType mt = ManagedType.GetManagedObject(value);
result = null;

// XXX - hack to support objects wrapped in old-style classes
// (such as exception objects).
if (Runtime.wrap_exceptions)
{
if (mt == null)
{
if (Runtime.PyObject_IsInstance(
value, Exceptions.Exception
) > 0)
{
IntPtr p = Runtime.PyObject_GetAttrString(value, "_inner");
if (p != IntPtr.Zero)
{
// This is safe because we know that the __dict__ of
// value holds a reference to _inner.
value = p;
Runtime.XDecref(p);
mt = ManagedType.GetManagedObject(value);
}
}
IntPtr c = Exceptions.UnwrapExceptionClass(value);
if ((c != IntPtr.Zero) && (c != value))
{
value = c;
Runtime.XDecref(c);
mt = ManagedType.GetManagedObject(value);
}
}
}

if (mt != null)
{
if (mt is CLRObject)
Expand Down
Loading

Back | FazBrowse Home | New Git URL