From 59b1c51daad161fc5f85452102188b75cc7284e3 Mon Sep 17 00:00:00 2001 From: Victor Nova Date: Thu, 14 Jul 2022 11:17:25 -0700 Subject: [PATCH 1/3] Finalizer.Instance.Collect() and Runtime.TryCollectingGarbage(...) are now callable from Python --- src/runtime/Finalizer.cs | 1 + src/runtime/Runtime.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/runtime/Finalizer.cs b/src/runtime/Finalizer.cs index e796cacd1..f4b465ecb 100644 --- a/src/runtime/Finalizer.cs +++ b/src/runtime/Finalizer.cs @@ -106,6 +106,7 @@ internal IncorrectRefCountException(IntPtr ptr) #endregion + [ForbidPythonThreads] public void Collect() => this.DisposeAll(); internal void ThrottledCollect() diff --git a/src/runtime/Runtime.cs b/src/runtime/Runtime.cs index 20bef23d4..88a8ed173 100644 --- a/src/runtime/Runtime.cs +++ b/src/runtime/Runtime.cs @@ -359,6 +359,7 @@ static bool TryCollectingGarbage(int runs, bool forceBreakLoops) /// /// Total number of GC loops to run /// true if a steady state was reached upon the requested number of tries (e.g. on the last try no objects were collected). + [ForbidPythonThreads] public static bool TryCollectingGarbage(int runs) => TryCollectingGarbage(runs, forceBreakLoops: false); From 469ec671fc9d7ee2f149a6687b5c7aeb5f861563 Mon Sep 17 00:00:00 2001 From: Victor Nova Date: Thu, 14 Jul 2022 11:18:01 -0700 Subject: [PATCH 2/3] fixed leak in NewReference.Move fixes https://github.com/pythonnet/pythonnet/issues/1872 --- src/runtime/Native/NewReference.cs | 2 +- tests/test_constructors.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/runtime/Native/NewReference.cs b/src/runtime/Native/NewReference.cs index 25145fc4f..f7a030818 100644 --- a/src/runtime/Native/NewReference.cs +++ b/src/runtime/Native/NewReference.cs @@ -47,7 +47,7 @@ public PyObject MoveToPyObject() /// public NewReference Move() { - var result = new NewReference(this); + var result = DangerousFromPointer(this.DangerousGetAddress()); this.pointer = default; return result; } diff --git a/tests/test_constructors.py b/tests/test_constructors.py index 6d8f00c12..3e0b1bb93 100644 --- a/tests/test_constructors.py +++ b/tests/test_constructors.py @@ -3,6 +3,7 @@ """Test CLR class constructor support.""" import pytest +import sys import System @@ -71,6 +72,19 @@ def test_default_constructor_fallback(): ob = DefaultConstructorMatching("2") +def test_constructor_leak(): + from System import Uri + from Python.Runtime import Runtime + + uri = Uri("http://www.python.org") + Runtime.TryCollectingGarbage(20) + ref_count = sys.getrefcount(uri) + + # check disabled due to GC uncertainty + # assert ref_count == 1 + + + def test_string_constructor(): from System import String, Char, Array From 93631aff83b34a0665374cd41313c8552b88b545 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Sat, 16 Jul 2022 12:08:59 +0200 Subject: [PATCH 3/3] Bump release candidate version --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index b9eb748c0..dc72b3783 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -3.0.0-rc3 +3.0.0-rc4 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy