| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 698bf00 commit 908e13b
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,8 +13,6 @@ static class PyIdentifier | |||
| 13 | 13 | public static BorrowedReference __doc__ => new(f__doc__); | |
| 14 | 14 | static IntPtr f__class__; | |
| 15 | 15 | public static BorrowedReference __class__ => new(f__class__); | |
| 16 | - static IntPtr f__clear_reentry_guard__; | ||
| 17 | - public static BorrowedReference __clear_reentry_guard__ => new(f__clear_reentry_guard__); | ||
| 18 | 16 | static IntPtr f__module__; | |
| 19 | 17 | public static BorrowedReference __module__ => new(f__module__); | |
| 20 | 18 | static IntPtr f__file__; | |
@@ -51,7 +49,6 @@ static partial class InternString | |||
| 51 | 49 | "__dict__", | |
| 52 | 50 | "__doc__", | |
| 53 | 51 | "__class__", | |
| 54 | - "__clear_reentry_guard__", | ||
| 55 | 52 | "__module__", | |
| 56 | 53 | "__file__", | |
| 57 | 54 | "__slots__", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,7 +7,6 @@ | |||
| 7 | 7 | "__dict__", | |
| 8 | 8 | "__doc__", | |
| 9 | 9 | "__class__", | |
| 10 | - "__clear_reentry_guard__", | ||
| 11 | 10 | "__module__", | |
| 12 | 11 | "__file__", | |
| 13 | 12 | "__slots__", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -374,6 +374,8 @@ public static int tp_clear(BorrowedReference ob) | |||
| 374 | 374 | return 0; | |
| 375 | 375 | } | |
| 376 | 376 | ||
| 377 | + static readonly HashSet<IntPtr> ClearVisited = new(); | ||
| 378 | + | ||
| 377 | 379 | internal static unsafe int BaseUnmanagedClear(BorrowedReference ob) | |
| 378 | 380 | { | |
| 379 | 381 | var type = Runtime.PyObject_TYPE(ob); | |
@@ -385,26 +387,20 @@ internal static unsafe int BaseUnmanagedClear(BorrowedReference ob) | |||
| 385 | 387 | } | |
| 386 | 388 | var clear = (delegate* unmanaged[Cdecl]<BorrowedReference, int>)clearPtr; | |
| 387 | 389 | ||
| 388 | - bool usesSubtypeClear = clearPtr == TypeManager.subtype_clear; | ||
| 389 | - if (usesSubtypeClear) | ||
| 390 | + if (clearPtr == TypeManager.subtype_clear) | ||
| 390 | 391 | { | |
| 391 | - // workaround for https://bugs.python.org/issue45266 (subtype_clear) | ||
| 392 | - using var dict = Runtime.PyObject_GenericGetDict(ob); | ||
| 393 | - if (Runtime.PyMapping_HasKey(dict.Borrow(), PyIdentifier.__clear_reentry_guard__) != 0) | ||
| 392 | + var addr = ob.DangerousGetAddress(); | ||
| 393 | + if (!ClearVisited.Add(addr)) | ||
| 394 | 394 | return 0; | |
| 395 | 395 | ||
| 396 | - int res = Runtime.PyDict_SetItem( | ||
| 397 | - dict.Borrow(), | ||
| 398 | - PyIdentifier.__clear_reentry_guard__, | ||
| 399 | - Runtime.PyTrue | ||
| 400 | - ); | ||
| 401 | - if (res != 0) return res; | ||
| 402 | - | ||
| 403 | - res = clear(ob); | ||
| 404 | - Runtime.PyDict_DelItem(dict.Borrow(), PyIdentifier.__clear_reentry_guard__); | ||
| 396 | + int res = clear(ob); | ||
| 397 | + ClearVisited.Remove(addr); | ||
| 405 | 398 | return res; | |
| 406 | 399 | } | |
| 407 | - return clear(ob); | ||
| 400 | + else | ||
| 401 | + { | ||
| 402 | + return clear(ob); | ||
| 403 | + } | ||
| 408 | 404 | } | |
| 409 | 405 | ||
| 410 | 406 | protected override Dictionary<string, object?> OnSave(BorrowedReference ob) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -942,7 +942,6 @@ def test_getting_generic_method_binding_does_not_leak_ref_count(): | |||
| 942 | 942 | refCount = sys.getrefcount(PlainOldClass().GenericMethod[str]) | |
| 943 | 943 | assert refCount == 1 | |
| 944 | 944 | ||
| 945 | - @pytest.mark.skipif(sys.version_info >= (3, 14), reason="Test skipped on Python 3.14 and above") | ||
| 946 | 945 | def test_getting_generic_method_binding_does_not_leak_memory(): | |
| 947 | 946 | """Test that managed object is freed after calling generic method. Issue #691""" | |
| 948 | 947 | ||
@@ -984,7 +983,6 @@ def test_getting_overloaded_method_binding_does_not_leak_ref_count(): | |||
| 984 | 983 | refCount = sys.getrefcount(PlainOldClass().OverloadedMethod.Overloads[int]) | |
| 985 | 984 | assert refCount == 1 | |
| 986 | 985 | ||
| 987 | - @pytest.mark.skipif(sys.version_info >= (3, 14), reason="Test skipped on Python 3.14 and above") | ||
| 988 | 986 | def test_getting_overloaded_method_binding_does_not_leak_memory(): | |
| 989 | 987 | """Test that managed object is freed after calling overloaded method. Issue #691""" | |
| 990 | 988 | ||
@@ -1027,7 +1025,6 @@ def test_getting_method_overloads_binding_does_not_leak_ref_count(): | |||
| 1027 | 1025 | assert refCount == 1 | |
| 1028 | 1026 | ||
| 1029 | 1027 | @pytest.mark.xfail(reason="Fails locally, need to investigate later", strict=False) | |
| 1030 | - @pytest.mark.skipif(sys.version_info >= (3, 14), reason="Test skipped on Python 3.14 and above") | ||
| 1031 | 1028 | def test_getting_method_overloads_binding_does_not_leak_memory(): | |
| 1032 | 1029 | """Test that managed object is freed after calling overloaded method. Issue #691""" | |
| 1033 | 1030 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -304,7 +304,6 @@ def __init__(self, i, s): | |||
| 304 | 304 | assert calls[0][1] == "foo" | |
| 305 | 305 | ||
| 306 | 306 | # regression test for https://github.com/pythonnet/pythonnet/issues/1565 | |
| 307 | - @pytest.mark.skipif(sys.version_info >= (3, 14), reason="Test skipped on Python 3.14 and above") | ||
| 308 | 307 | def test_can_be_collected_by_gc(): | |
| 309 | 308 | from Python.Test import BaseClass | |
| 310 | 309 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments