Skip to content

Commit 21cb776

Browse files
NickSavinfilmor
authored andcommitted
Encode strings passed to PyRun_String as UTF8
1 parent f2f5955 commit 21cb776

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/runtime/runtime.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,11 @@ public static extern int Py_Main(
839839
internal static extern int PyRun_SimpleString(string code);
840840

841841
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
842+
#if PYTHON2
842843
internal static extern NewReference PyRun_String(string code, IntPtr st, IntPtr globals, IntPtr locals);
844+
#else
845+
internal static extern NewReference PyRun_String([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string code, IntPtr st, IntPtr globals, IntPtr locals);
846+
#endif
843847

844848
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
845849
internal static extern IntPtr PyEval_EvalCode(IntPtr co, IntPtr globals, IntPtr locals);

0 commit comments

Comments
 (0)