| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -106,6 +106,7 @@ internal IncorrectRefCountException(IntPtr ptr) | |||
| 106 | 106 | ||
| 107 | 107 | #endregion | |
| 108 | 108 | ||
| 109 | + [ForbidPythonThreads] | ||
| 109 | 110 | public void Collect() => this.DisposeAll(); | |
| 110 | 111 | ||
| 111 | 112 | internal void ThrottledCollect() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -47,7 +47,7 @@ public PyObject MoveToPyObject() | |||
| 47 | 47 | /// </summary> | |
| 48 | 48 | public NewReference Move() | |
| 49 | 49 | { | |
| 50 | - var result = new NewReference(this); | ||
| 50 | + var result = DangerousFromPointer(this.DangerousGetAddress()); | ||
| 51 | 51 | this.pointer = default; | |
| 52 | 52 | return result; | |
| 53 | 53 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -359,6 +359,7 @@ static bool TryCollectingGarbage(int runs, bool forceBreakLoops) | |||
| 359 | 359 | /// </summary> | |
| 360 | 360 | /// <param name="runs">Total number of GC loops to run</param> | |
| 361 | 361 | /// <returns><c>true</c> if a steady state was reached upon the requested number of tries (e.g. on the last try no objects were collected).</returns> | |
| 362 | + [ForbidPythonThreads] | ||
| 362 | 363 | public static bool TryCollectingGarbage(int runs) | |
| 363 | 364 | => TryCollectingGarbage(runs, forceBreakLoops: false); | |
| 364 | 365 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,6 +3,7 @@ | |||
| 3 | 3 | """Test CLR class constructor support.""" | |
| 4 | 4 | ||
| 5 | 5 | import pytest | |
| 6 | + import sys | ||
| 6 | 7 | ||
| 7 | 8 | import System | |
| 8 | 9 | ||
@@ -71,6 +72,19 @@ def test_default_constructor_fallback(): | |||
| 71 | 72 | ob = DefaultConstructorMatching("2") | |
| 72 | 73 | ||
| 73 | 74 | ||
| 75 | + def test_constructor_leak(): | ||
| 76 | + from System import Uri | ||
| 77 | + from Python.Runtime import Runtime | ||
| 78 | + | ||
| 79 | + uri = Uri("http://www.python.org") | ||
| 80 | + Runtime.TryCollectingGarbage(20) | ||
| 81 | + ref_count = sys.getrefcount(uri) | ||
| 82 | + | ||
| 83 | + # check disabled due to GC uncertainty | ||
| 84 | + # assert ref_count == 1 | ||
| 85 | + | ||
| 86 | + | ||
| 87 | + | ||
| 74 | 88 | def test_string_constructor(): | |
| 75 | 89 | from System import String, Char, Array | |
| 76 | 90 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments