| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8fb4704 commit 2679c19
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -46,6 +46,22 @@ public static void LoadSpecificArgs() | |||
| 46 | 46 | } | |
| 47 | 47 | } | |
| 48 | 48 | ||
| 49 | + // regression test for https://github.com/pythonnet/pythonnet/issues/1561 | ||
| 50 | + [Test] | ||
| 51 | + public void ImportClassShutdownRefcount() | ||
| 52 | + { | ||
| 53 | + PythonEngine.Initialize(); | ||
| 54 | + | ||
| 55 | + PyObject ns = Py.Import(typeof(ImportClassShutdownRefcountClass).Namespace); | ||
| 56 | + PyObject cls = ns.GetAttr(nameof(ImportClassShutdownRefcountClass)); | ||
| 57 | + ns.Dispose(); | ||
| 58 | + | ||
| 59 | + Assert.Less(cls.Refcount, 256); | ||
| 60 | + | ||
| 61 | + PythonEngine.Shutdown(); | ||
| 62 | + Assert.Greater(cls.Refcount, 0); | ||
| 63 | + } | ||
| 64 | + | ||
| 49 | 65 | /// <summary> | |
| 50 | 66 | /// Failing test demonstrating current issue with OverflowException (#376) | |
| 51 | 67 | /// and ArgumentException issue after that one is fixed. | |
@@ -182,4 +198,6 @@ public static void TestRunExitFuncs() | |||
| 182 | 198 | Assert.True(called); | |
| 183 | 199 | } | |
| 184 | 200 | } | |
| 201 | + | ||
| 202 | + public class ImportClassShutdownRefcountClass { } | ||
| 185 | 203 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -67,7 +67,6 @@ internal static void DisposePythonWrappersForClrTypes() | |||
| 67 | 67 | // since others may still referencing it. | |
| 68 | 68 | cls.CallTypeTraverse(TraverseTypeClear, visitedPtr); | |
| 69 | 69 | cls.CallTypeClear(); | |
| 70 | - cls.DecrRefCount(); | ||
| 71 | 70 | } | |
| 72 | 71 | } | |
| 73 | 72 | finally | |
| Back | FazBrowse Home | New Git URL |
0 commit comments