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

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions 3 src/runtime/clrobject.cs
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 45 src/runtime/converter.cs
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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.