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__cause__ on overload bind failure and array conversion#1442

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
lostmsu merged 1 commit intopythonnet:masterfromlosttech:PR/PythonDebugBuild
Apr 14, 2021
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
5 changes: 5 additions & 0 deletionssrc/runtime/converter.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -814,9 +814,14 @@ private static bool ToPrimitive(IntPtr value, Type obType, out object result, bo

privatestaticvoidSetConversionError(IntPtrvalue,Typetarget)
{
// PyObject_Repr might clear the error
Runtime.PyErr_Fetch(outvarcauseType,outvarcauseVal,outvarcauseTrace);

IntPtrob=Runtime.PyObject_Repr(value);
stringsrc=Runtime.GetManagedString(ob);
Runtime.XDecref(ob);

Runtime.PyErr_Restore(causeType,causeVal,causeTrace);
Exceptions.RaiseTypeError($"Cannot convert{src} to{target}");
}

Expand Down
2 changes: 1 addition & 1 deletionsrc/runtime/finalizer.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -54,7 +54,7 @@ public class IncorrectRefCountException : Exception
publicIncorrectRefCountException(IntPtrptr)
{
PyPtr=ptr;
IntPtrpyname=Runtime.PyObject_Unicode(PyPtr);
IntPtrpyname=Runtime.PyObject_Str(PyPtr);
stringname=Runtime.GetManagedString(pyname);
Runtime.XDecref(pyname);
_message=$"<{name}> may has a incorrect ref count";
Expand Down
4 changes: 3 additions & 1 deletionsrc/runtime/methodbinder.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -876,7 +876,7 @@ protected static void AppendArgumentTypes(StringBuilder to, IntPtr args)
{
try
{
vardescription=Runtime.PyObject_Unicode(type);
vardescription=Runtime.PyObject_Str(type);
if(description!=IntPtr.Zero)
{
to.Append(Runtime.GetManagedString(description));
Expand DownExpand Up@@ -926,7 +926,9 @@ internal virtual IntPtr Invoke(IntPtr inst, IntPtr args, IntPtr kw, MethodBase i
}

value.Append(": ");
Runtime.PyErr_Fetch(outvarerrType,outvarerrVal,outvarerrTrace);
Copy link
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
MemberAuthor

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());
returnIntPtr.Zero;
}
Expand Down
2 changes: 1 addition & 1 deletionsrc/runtime/pyobject.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1040,7 +1040,7 @@ public string Repr()
/// </remarks>
publicoverridestringToString()
{
IntPtrstrval=Runtime.PyObject_Unicode(obj);
IntPtrstrval=Runtime.PyObject_Str(obj);
stringresult=Runtime.GetManagedString(strval);
Runtime.XDecref(strval);
returnresult;
Expand Down
20 changes: 11 additions & 9 deletionssrc/runtime/runtime.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
usingSystem.Reflection.Emit;
usingSystem;
usingSystem.Diagnostics;
usingSystem.Diagnostics.Contracts;
usingSystem.Runtime.InteropServices;
usingSystem.Security;
usingSystem.Text;
usingSystem.Threading;
usingSystem.Collections.Generic;
Expand DownExpand Up@@ -1127,13 +1126,18 @@ internal static int PyObject_Compare(IntPtr value1, IntPtr value2)
internalstaticnintPyObject_Hash(IntPtrop)=>Delegates.PyObject_Hash(op);


internalstaticIntPtrPyObject_Repr(IntPtrpointer)=>Delegates.PyObject_Repr(pointer);


internalstaticIntPtrPyObject_Str(IntPtrpointer)=>Delegates.PyObject_Str(pointer);
internalstaticIntPtrPyObject_Repr(IntPtrpointer)
{
Debug.Assert(PyErr_Occurred()==IntPtr.Zero);
returnDelegates.PyObject_Repr(pointer);
}


internalstaticIntPtrPyObject_Unicode(IntPtrpointer)=>Delegates.PyObject_Unicode(pointer);
internalstaticIntPtrPyObject_Str(IntPtrpointer)
{
Debug.Assert(PyErr_Occurred()==IntPtr.Zero);
returnDelegates.PyObject_Str(pointer);
}


internalstaticIntPtrPyObject_Dir(IntPtrpointer)=>Delegates.PyObject_Dir(pointer);
Expand DownExpand Up@@ -2322,7 +2326,6 @@ static Delegates()
PyObject_Hash=(delegate* unmanaged[Cdecl]<IntPtr,IntPtr>)GetFunctionByName(nameof(PyObject_Hash),GetUnmanagedDll(_PythonDll));
PyObject_Repr=(delegate* unmanaged[Cdecl]<IntPtr,IntPtr>)GetFunctionByName(nameof(PyObject_Repr),GetUnmanagedDll(_PythonDll));
PyObject_Str=(delegate* unmanaged[Cdecl]<IntPtr,IntPtr>)GetFunctionByName(nameof(PyObject_Str),GetUnmanagedDll(_PythonDll));
PyObject_Unicode=(delegate* unmanaged[Cdecl]<IntPtr,IntPtr>)GetFunctionByName("PyObject_Str",GetUnmanagedDll(_PythonDll));
PyObject_Dir=(delegate* unmanaged[Cdecl]<IntPtr,IntPtr>)GetFunctionByName(nameof(PyObject_Dir),GetUnmanagedDll(_PythonDll));
PyObject_GetBuffer=(delegate* unmanaged[Cdecl]<IntPtr,refPy_buffer,int,int>)GetFunctionByName(nameof(PyObject_GetBuffer),GetUnmanagedDll(_PythonDll));
PyBuffer_Release=(delegate* unmanaged[Cdecl]<refPy_buffer,void>)GetFunctionByName(nameof(PyBuffer_Release),GetUnmanagedDll(_PythonDll));
Expand DownExpand Up@@ -2607,7 +2610,6 @@ static Delegates()
internalstaticdelegate* unmanaged[Cdecl]<IntPtr,IntPtr>PyObject_Hash{get;}
internalstaticdelegate* unmanaged[Cdecl]<IntPtr,IntPtr>PyObject_Repr{get;}
internalstaticdelegate* unmanaged[Cdecl]<IntPtr,IntPtr>PyObject_Str{get;}
internalstaticdelegate* unmanaged[Cdecl]<IntPtr,IntPtr>PyObject_Unicode{get;}
internalstaticdelegate* unmanaged[Cdecl]<IntPtr,IntPtr>PyObject_Dir{get;}
internalstaticdelegate* unmanaged[Cdecl]<IntPtr,refPy_buffer,int,int>PyObject_GetBuffer{get;}
internalstaticdelegate* unmanaged[Cdecl]<refPy_buffer,void>PyBuffer_Release{get;}
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp