| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -40,27 +40,16 @@ public static void PlatformCache() | |||
| 40 | 40 | [Test] | |
| 41 | 41 | public static void Py_IsInitializedValue() | |
| 42 | 42 | { | |
| 43 | - IntPtr state = IntPtr.Zero; | ||
| 44 | - try | ||
| 43 | + if (Runtime.Runtime.Py_IsInitialized() == 1) | ||
| 45 | 44 | { | |
| 46 | - if (Runtime.Runtime.Py_IsInitialized() == 1) | ||
| 47 | - { | ||
| 48 | - state = Runtime.Runtime.PyGILState_Ensure(); | ||
| 49 | - } | ||
| 50 | - Runtime.Runtime.Py_Finalize(); | ||
| 51 | - Assert.AreEqual(0, Runtime.Runtime.Py_IsInitialized()); | ||
| 52 | - Runtime.Runtime.Py_Initialize(); | ||
| 53 | - Assert.AreEqual(1, Runtime.Runtime.Py_IsInitialized()); | ||
| 54 | - Runtime.Runtime.Py_Finalize(); | ||
| 55 | - Assert.AreEqual(0, Runtime.Runtime.Py_IsInitialized()); | ||
| 56 | - } | ||
| 57 | - finally | ||
| 58 | - { | ||
| 59 | - if(state != IntPtr.Zero) | ||
| 60 | - { | ||
| 61 | - Runtime.Runtime.PyGILState_Release(state); | ||
| 62 | - } | ||
| 45 | + Runtime.Runtime.PyGILState_Ensure(); | ||
| 63 | 46 | } | |
| 47 | + Runtime.Runtime.Py_Finalize(); | ||
| 48 | + Assert.AreEqual(0, Runtime.Runtime.Py_IsInitialized()); | ||
| 49 | + Runtime.Runtime.Py_Initialize(); | ||
| 50 | + Assert.AreEqual(1, Runtime.Runtime.Py_IsInitialized()); | ||
| 51 | + Runtime.Runtime.Py_Finalize(); | ||
| 52 | + Assert.AreEqual(0, Runtime.Runtime.Py_IsInitialized()); | ||
| 64 | 53 | } | |
| 65 | 54 | ||
| 66 | 55 | [Test] | |
| Back | FazBrowse Home | New Git URL |
0 commit comments