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

Commit139dc87

Browse files
filmorlostmsu
authored andcommitted
Ensure that all *String C-API functions are used with UTF8
1 parent6a5c3a4 commit139dc87

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

‎src/runtime/runtime.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,16 +1024,13 @@ internal static bool PyObject_IsIterable(IntPtr pointer)
10241024
}
10251025

10261026
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
1027-
internal static extern int PyObject_HasAttrString(IntPtr pointer, string name);
1027+
internal static extern int PyObject_HasAttrString(IntPtr pointer,[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string name);
10281028

10291029
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
1030-
internal static extern IntPtr PyObject_GetAttrString(IntPtr pointer, string name);
1030+
internal static extern IntPtr PyObject_GetAttrString(IntPtr pointer,[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string name);
10311031

10321032
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
1033-
internal static extern IntPtr PyObject_GetAttrString(IntPtr pointer, IntPtr name);
1034-
1035-
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
1036-
internal static extern int PyObject_SetAttrString(IntPtr pointer, string name, IntPtr value);
1033+
internal static extern int PyObject_SetAttrString(IntPtr pointer, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name, IntPtr value);
10371034

10381035
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
10391036
internal static extern int PyObject_HasAttr(IntPtr pointer, IntPtr name);
@@ -1648,7 +1645,7 @@ internal static bool PyDict_Check(IntPtr ob)
16481645
/// Return value: Borrowed reference.
16491646
/// </summary>
16501647
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
1651-
internal static extern IntPtr PyDict_GetItemString(IntPtr pointer, string key);
1648+
internal static extern IntPtr PyDict_GetItemString(IntPtr pointer,[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string key);
16521649

16531650
/// <summary>
16541651
/// Return 0 on success or -1 on failure.
@@ -1660,13 +1657,13 @@ internal static bool PyDict_Check(IntPtr ob)
16601657
/// Return 0 on success or -1 on failure.
16611658
/// </summary>
16621659
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
1663-
internal static extern int PyDict_SetItemString(IntPtr pointer, string key, IntPtr value);
1660+
internal static extern int PyDict_SetItemString(IntPtr pointer,[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string key, IntPtr value);
16641661

16651662
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
16661663
internal static extern int PyDict_DelItem(IntPtr pointer, IntPtr key);
16671664

16681665
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
1669-
internal static extern int PyDict_DelItemString(IntPtr pointer, string key);
1666+
internal static extern int PyDict_DelItemString(IntPtr pointer,[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string key);
16701667

16711668
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
16721669
internal static extern int PyMapping_HasKey(IntPtr pointer, IntPtr key);
@@ -2018,7 +2015,7 @@ internal static IntPtr PyMem_Realloc(IntPtr ptr, long size)
20182015
//====================================================================
20192016

20202017
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
2021-
internal static extern void PyErr_SetString(IntPtr ob, string message);
2018+
internal static extern void PyErr_SetString(IntPtr ob,[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string message);
20222019

20232020
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
20242021
internal static extern void PyErr_SetObject(BorrowedReference type, BorrowedReference exceptionObject);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp