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

Commit7765474

Browse files
rmadsen-ksfilmor
authored andcommitted
Fixedpythonnet#449, by added initSigs as an optional parameter to PythonEngine.Initialize.
1 parent5c9f035 commit7765474

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

‎src/runtime/pythonengine.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ public static void Initialize()
140140
Initialize(setSysArgv:true);
141141
}
142142

143-
publicstaticvoidInitialize(boolsetSysArgv=true)
143+
publicstaticvoidInitialize(boolsetSysArgv=true,boolinitSigs=false)
144144
{
145-
Initialize(Enumerable.Empty<string>(),setSysArgv:setSysArgv);
145+
Initialize(Enumerable.Empty<string>(),setSysArgv:setSysArgv,initSigs:initSigs);
146146
}
147147

148148
/// <summary>
@@ -153,8 +153,9 @@ public static void Initialize(bool setSysArgv = true)
153153
/// more than once, though initialization will only happen on the
154154
/// first call. It is *not* necessary to hold the Python global
155155
/// interpreter lock (GIL) to call this method.
156+
/// initSigs can be set to 1 to do default python signal configuration. This will override the way signals are handled by the application.
156157
/// </remarks>
157-
publicstaticvoidInitialize(IEnumerable<string>args,boolsetSysArgv=true)
158+
publicstaticvoidInitialize(IEnumerable<string>args,boolsetSysArgv=true,boolinitSigs=false)
158159
{
159160
if(!initialized)
160161
{
@@ -164,7 +165,7 @@ public static void Initialize(IEnumerable<string> args, bool setSysArgv = true)
164165
// during an initial "import clr", and the world ends shortly thereafter.
165166
// This is probably masking some bad mojo happening somewhere in Runtime.Initialize().
166167
delegateManager=newDelegateManager();
167-
Runtime.Initialize();
168+
Runtime.Initialize(initSigs);
168169
initialized=true;
169170
Exceptions.Clear();
170171

‎src/runtime/runtime.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,11 @@ public enum MachineType
269269
/// <summary>
270270
/// Initialize the runtime...
271271
/// </summary>
272-
internalstaticvoidInitialize()
272+
internalstaticvoidInitialize(boolinitSigs)
273273
{
274274
if(Py_IsInitialized()==0)
275275
{
276-
Py_Initialize();
276+
Py_InitializeEx(initSigs?1:0);
277277
}
278278

279279
if(PyEval_ThreadsInitialized()==0)
@@ -727,6 +727,9 @@ internal static unsafe long Refcount(IntPtr op)
727727
[DllImport(_PythonDll,CallingConvention=CallingConvention.Cdecl)]
728728
internalstaticexternvoid Py_Initialize();
729729

730+
[DllImport(_PythonDll,CallingConvention=CallingConvention.Cdecl)]
731+
internalstaticexternvoid Py_InitializeEx(intinitsigs);
732+
730733
[DllImport(_PythonDll,CallingConvention=CallingConvention.Cdecl)]
731734
internalstaticexternint Py_IsInitialized();
732735

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp