FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Encode strings passed to PyRun_String as UTF8 · sdpython/pythonnet@21cb776 · GitHub

This repository was archived by the owner on Jul 22, 2023. It is now read-only.

Repository navigation

Commit 21cb776

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

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎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)

Back | FazBrowse Home | New Git URL