diff --git a/appveyor.yml b/appveyor.yml index 6bebef490..edd3c153b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -66,6 +66,9 @@ on_finish: artifacts: - path: dist\* + - path: TestResult.xml + name: TestResult + type: xml notifications: - provider: Slack diff --git a/src/embed_tests/Python.EmbeddingTest.csproj b/src/embed_tests/Python.EmbeddingTest.csproj index 66e8c7165..7c627327d 100644 --- a/src/embed_tests/Python.EmbeddingTest.csproj +++ b/src/embed_tests/Python.EmbeddingTest.csproj @@ -80,6 +80,7 @@ + diff --git a/src/embed_tests/TestConsoleInterrupt.cs b/src/embed_tests/TestConsoleInterrupt.cs new file mode 100644 index 000000000..0b96e9c76 Binary files /dev/null and b/src/embed_tests/TestConsoleInterrupt.cs differ diff --git a/src/runtime/pythonengine.cs b/src/runtime/pythonengine.cs index a23c7ac79..b37c91bec 100644 --- a/src/runtime/pythonengine.cs +++ b/src/runtime/pythonengine.cs @@ -140,9 +140,9 @@ public static void Initialize() Initialize(setSysArgv: true); } - public static void Initialize(bool setSysArgv = true) + public static void Initialize(bool setSysArgv = true, bool initSigs = false) { - Initialize(Enumerable.Empty(), setSysArgv: setSysArgv); + Initialize(Enumerable.Empty(), setSysArgv: setSysArgv, initSigs: initSigs); } /// @@ -153,8 +153,9 @@ public static void Initialize(bool setSysArgv = true) /// more than once, though initialization will only happen on the /// first call. It is *not* necessary to hold the Python global /// interpreter lock (GIL) to call this method. + /// initSigs can be set to 1 to do default python signal configuration. This will override the way signals are handled by the application. /// - public static void Initialize(IEnumerable args, bool setSysArgv = true) + public static void Initialize(IEnumerable args, bool setSysArgv = true, bool initSigs = false) { if (!initialized) { @@ -164,7 +165,7 @@ public static void Initialize(IEnumerable args, bool setSysArgv = true) // during an initial "import clr", and the world ends shortly thereafter. // This is probably masking some bad mojo happening somewhere in Runtime.Initialize(). delegateManager = new DelegateManager(); - Runtime.Initialize(); + Runtime.Initialize(initSigs); initialized = true; Exceptions.Clear(); diff --git a/src/runtime/runtime.cs b/src/runtime/runtime.cs index b08a56622..b6563c445 100644 --- a/src/runtime/runtime.cs +++ b/src/runtime/runtime.cs @@ -206,11 +206,11 @@ public class Runtime /// /// Initialize the runtime... /// - internal static void Initialize() + internal static void Initialize(bool initSigs) { if (Py_IsInitialized() == 0) { - Py_Initialize(); + Py_InitializeEx(initSigs ? 1 : 0); } if (PyEval_ThreadsInitialized() == 0) @@ -604,6 +604,9 @@ internal static unsafe long Refcount(IntPtr op) [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern void Py_Initialize(); + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void Py_InitializeEx(int initsigs); + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern int Py_IsInitialized();