| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 012b488 commit faf5faf
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -122,7 +122,12 @@ public static int RunSimpleString(string code) | |||
| 122 | 122 | ||
| 123 | 123 | public static void Initialize() | |
| 124 | 124 | { | |
| 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); | ||
| 126 | 131 | } | |
| 127 | 132 | ||
| 128 | 133 | /// <summary> | |
@@ -134,7 +139,7 @@ public static void Initialize() | |||
| 134 | 139 | /// first call. It is *not* necessary to hold the Python global | |
| 135 | 140 | /// interpreter lock (GIL) to call this method. | |
| 136 | 141 | /// </remarks> | |
| 137 | - public static void Initialize(IEnumerable<string> args) | ||
| 142 | + public static void Initialize(IEnumerable<string> args, bool setSysArgv = true) | ||
| 138 | 143 | { | |
| 139 | 144 | if (!initialized) | |
| 140 | 145 | { | |
@@ -148,7 +153,8 @@ public static void Initialize(IEnumerable<string> args) | |||
| 148 | 153 | initialized = true; | |
| 149 | 154 | Exceptions.Clear(); | |
| 150 | 155 | ||
| 151 | - Py.SetArgv(args); | ||
| 156 | + if (setSysArgv) | ||
| 157 | + Py.SetArgv(args); | ||
| 152 | 158 | ||
| 153 | 159 | // register the atexit callback (this doesn't use Py_AtExit as the C atexit | |
| 154 | 160 | // callbacks are called after python is fully finalized but the python ones | |
@@ -213,7 +219,7 @@ public static void InitExt() | |||
| 213 | 219 | { | |
| 214 | 220 | try | |
| 215 | 221 | { | |
| 216 | - Initialize(); | ||
| 222 | + Initialize(setSysArgv: false); | ||
| 217 | 223 | ||
| 218 | 224 | // Trickery - when the import hook is installed into an already | |
| 219 | 225 | // running Python, the standard import machinery is still in | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,12 +4,9 @@ | |||
| 4 | 4 | ||
| 5 | 5 | import sys | |
| 6 | 6 | ||
| 7 | - import pytest | ||
| 8 | - | ||
| 9 | 7 | from ._compat import check_output | |
| 10 | 8 | ||
| 11 | 9 | ||
| 12 | - @pytest.mark.xfail(reason="argv being reset on import clr. See gh#404") | ||
| 13 | 10 | def test_sys_argv_state(filepath): | |
| 14 | 11 | """Test sys.argv state doesn't change after clr import. | |
| 15 | 12 | To better control the arguments being passed, test on a fresh python | |
| Back | FazBrowse Home | New Git URL |
0 commit comments