Skip to content

Commit 5633ee6

Browse files
committed
Fix crash because Python 3 C API does not have PyNumber_Int
1 parent 30d9db1 commit 5633ee6

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎pythonnet/src/runtime/runtime.cs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,10 +824,18 @@ internal unsafe static extern IntPtr
824824
// Python number API
825825
//====================================================================
826826

827+
#if (PYTHON32 || PYTHON33 || PYTHON34)
827828
[DllImport(Runtime.dll, CallingConvention=CallingConvention.Cdecl,
829+
EntryPoint = "PyNumber_Long",
828830
ExactSpelling=true, CharSet=CharSet.Ansi)]
829831
internal unsafe static extern IntPtr
830832
PyNumber_Int(IntPtr ob);
833+
#else // Python 2
834+
[DllImport(Runtime.dll, CallingConvention=CallingConvention.Cdecl,
835+
ExactSpelling=true, CharSet=CharSet.Ansi)]
836+
internal unsafe static extern IntPtr
837+
PyNumber_Int(IntPtr ob);
838+
#endif
831839

832840
[DllImport(Runtime.dll, CallingConvention=CallingConvention.Cdecl,
833841
ExactSpelling=true, CharSet=CharSet.Ansi)]

0 commit comments

Comments
 (0)