File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -122,7 +122,12 @@ public static int RunSimpleString(string code)
122122
123123 public static void Initialize ( )
124124 {
125- Initialize ( Enumerable . Empty < string > ( ) ) ;
125+ Initialize ( setSysArgv : true ) ;
126+ }
127+
128+ public static void Initialize ( bool setSysArgv = true )
129+ {
130+ Initialize ( Enumerable . Empty < string > ( ) , setSysArgv : setSysArgv ) ;
126131 }
127132
128133 /// <summary>
@@ -134,7 +139,7 @@ public static void Initialize()
134139 /// first call. It is *not* necessary to hold the Python global
135140 /// interpreter lock (GIL) to call this method.
136141 /// </remarks>
137- public static void Initialize ( IEnumerable < string > args )
142+ public static void Initialize ( IEnumerable < string > args , bool setSysArgv = true )
138143 {
139144 if ( ! initialized )
140145 {
@@ -148,7 +153,8 @@ public static void Initialize(IEnumerable<string> args)
148153 initialized = true ;
149154 Exceptions . Clear ( ) ;
150155
151- Py . SetArgv ( args ) ;
156+ if ( setSysArgv )
157+ Py . SetArgv ( args ) ;
152158
153159 // register the atexit callback (this doesn't use Py_AtExit as the C atexit
154160 // callbacks are called after python is fully finalized but the python ones
@@ -213,7 +219,7 @@ public static void InitExt()
213219 {
214220 try
215221 {
216- Initialize ( ) ;
222+ Initialize ( setSysArgv : false ) ;
217223
218224 // Trickery - when the import hook is installed into an already
219225 // running Python, the standard import machinery is still in
You can’t perform that action at this time.
0 commit comments