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
This repository was archived by the owner on Jul 22, 2023. It is now read-only.
/pythonnetPublic archive
forked frompythonnet/pythonnet

Commitf1da55e

Browse files
jmlidbetterfilmor
authored andcommitted
Fixes bug where there is casting on delegates -- this is explicitly in the NET standard documentation for GetDelegateForFunctionPointer (pythonnet#936)
1 parent51a1868 commitf1da55e

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

‎CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
1717
- Moved wheel import in setup.py inside of a try/except to prevent pip collection failures
1818
- Removes PyLong_GetMax and PyClass_New when targetting Python3
1919
- Added support for converting python iterators to C# arrays
20+
- Changed usage of obselete function GetDelegateForFunctionPointer(IntPtr, Type) to GetDelegateForFunctionPointer<TDelegate>(IntPtr)
2021

2122
###Fixed
2223

2324
- Fixed runtime that fails loading when using pythonnet in an environment
2425
together with Nuitka
26+
- Fixes bug where delegates get casts (dotnetcore)
2527

2628
##[2.4.0][]
2729

‎src/runtime/nativecall.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,21 @@ internal class NativeCall
3232

3333
publicstaticvoidVoid_Call_1(IntPtrfp,IntPtra1)
3434
{
35-
((Void_1_Delegate)Marshal.GetDelegateForFunctionPointer(fp,typeof(Void_1_Delegate)))(a1);
35+
vard=Marshal.GetDelegateForFunctionPointer<Interop.DestructorFunc>(fp);
36+
d(a1);
3637
}
3738

3839
publicstaticIntPtrCall_3(IntPtrfp,IntPtra1,IntPtra2,IntPtra3)
3940
{
40-
vard=(Interop.TernaryFunc)Marshal.GetDelegateForFunctionPointer(fp,typeof(Interop.TernaryFunc));
41+
vard=Marshal.GetDelegateForFunctionPointer<Interop.TernaryFunc>(fp);
4142
returnd(a1,a2,a3);
4243
}
4344

4445

4546
publicstaticintInt_Call_3(IntPtrfp,IntPtra1,IntPtra2,IntPtra3)
4647
{
47-
return((Int_3_Delegate)Marshal.GetDelegateForFunctionPointer(fp,typeof(Int_3_Delegate)))(a1,a2,a3);
48+
vard=Marshal.GetDelegateForFunctionPointer<Interop.ObjObjArgFunc>(fp);
49+
returnd(a1,a2,a3);
4850
}
4951
#else
5052
privatestaticAssemblyBuilderaBuilder;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp