Fixed `__cause__` on overload bind failure and array conversion by lostmsu · Pull Request #1442 · pythonnet/pythonnet · GitHub
Skip to content
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
5 changes: 5 additions & 0 deletions src/runtime/converter.cs
2 changes: 1 addition & 1 deletion src/runtime/finalizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class IncorrectRefCountException : Exception
public IncorrectRefCountException(IntPtr ptr)
{
PyPtr = ptr;
IntPtr pyname = Runtime.PyObject_Unicode(PyPtr);
IntPtr pyname = Runtime.PyObject_Str(PyPtr);
string name = Runtime.GetManagedString(pyname);
Runtime.XDecref(pyname);
_message = $"<{name}> may has a incorrect ref count";
Expand Down
4 changes: 3 additions & 1 deletion src/runtime/methodbinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ protected static void AppendArgumentTypes(StringBuilder to, IntPtr args)
{
try
{
var description = Runtime.PyObject_Unicode(type);
var description = Runtime.PyObject_Str(type);
if (description != IntPtr.Zero)
{
to.Append(Runtime.GetManagedString(description));
Expand Down Expand Up @@ -926,7 +926,9 @@ internal virtual IntPtr Invoke(IntPtr inst, IntPtr args, IntPtr kw, MethodBase i
}

value.Append(": ");
Runtime.PyErr_Fetch(out var errType, out var errVal, out var errTrace);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might also be a fix for #1371

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might let us reenable the test case, but the issue that caused it will still be there.

AppendArgumentTypes(to: value, args);
Runtime.PyErr_Restore(errType, errVal, errTrace);
Exceptions.RaiseTypeError(value.ToString());
return IntPtr.Zero;
}
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/pyobject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ public string Repr()
/// </remarks>
public override string ToString()
{
IntPtr strval = Runtime.PyObject_Unicode(obj);
IntPtr strval = Runtime.PyObject_Str(obj);
string result = Runtime.GetManagedString(strval);
Runtime.XDecref(strval);
return result;
Expand Down
20 changes: 11 additions & 9 deletions src/runtime/runtime.cs