diff --git a/src/runtime/runtime.cs b/src/runtime/runtime.cs index 374e88cf6..10cbdc869 100644 --- a/src/runtime/runtime.cs +++ b/src/runtime/runtime.cs @@ -1024,16 +1024,13 @@ internal static bool PyObject_IsIterable(IntPtr pointer) } [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyObject_HasAttrString(IntPtr pointer, string name); + internal static extern int PyObject_HasAttrString(IntPtr pointer, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name); [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyObject_GetAttrString(IntPtr pointer, string name); + internal static extern IntPtr PyObject_GetAttrString(IntPtr pointer, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name); [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyObject_GetAttrString(IntPtr pointer, IntPtr name); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyObject_SetAttrString(IntPtr pointer, string name, IntPtr value); + internal static extern int PyObject_SetAttrString(IntPtr pointer, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name, IntPtr value); [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern int PyObject_HasAttr(IntPtr pointer, IntPtr name); @@ -1648,7 +1645,7 @@ internal static bool PyDict_Check(IntPtr ob) /// Return value: Borrowed reference. /// [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyDict_GetItemString(IntPtr pointer, string key); + internal static extern IntPtr PyDict_GetItemString(IntPtr pointer, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string key); /// /// Return 0 on success or -1 on failure. @@ -1660,13 +1657,13 @@ internal static bool PyDict_Check(IntPtr ob) /// Return 0 on success or -1 on failure. /// [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyDict_SetItemString(IntPtr pointer, string key, IntPtr value); + internal static extern int PyDict_SetItemString(IntPtr pointer, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string key, IntPtr value); [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern int PyDict_DelItem(IntPtr pointer, IntPtr key); [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyDict_DelItemString(IntPtr pointer, string key); + internal static extern int PyDict_DelItemString(IntPtr pointer, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string key); [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern int PyMapping_HasKey(IntPtr pointer, IntPtr key); @@ -2018,7 +2015,7 @@ internal static IntPtr PyMem_Realloc(IntPtr ptr, long size) //==================================================================== [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void PyErr_SetString(IntPtr ob, string message); + internal static extern void PyErr_SetString(IntPtr ob, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string message); [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern void PyErr_SetObject(BorrowedReference type, BorrowedReference exceptionObject); diff --git a/src/testing/methodtest.cs b/src/testing/methodtest.cs index cd4a740d5..f5d694488 100644 --- a/src/testing/methodtest.cs +++ b/src/testing/methodtest.cs @@ -713,6 +713,10 @@ public static string ParamsArrayOverloaded(int i, params int[] paramsArray) { return "with params-array"; } + + public static void EncodingTestÅngström() + { + } } diff --git a/src/tests/test_method.py b/src/tests/test_method.py index c7859e881..18eb5af8e 100644 --- a/src/tests/test_method.py +++ b/src/tests/test_method.py @@ -1221,3 +1221,5 @@ def test_params_array_overload(): # res = MethodTest.ParamsArrayOverloaded(paramsArray=[], i=1) # assert res == "with params-array" +def test_method_encoding(): + MethodTest.EncodingTestÅngström()