Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3e284e5

Browse files
committed
fixed leak in NewReference.Move
fixes#1872
1 parent59b1c51 commit3e284e5

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

‎src/runtime/Native/NewReference.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public PyObject MoveToPyObject()
4747
/// </summary>
4848
publicNewReferenceMove()
4949
{
50-
varresult=newNewReference(this);
50+
varresult=DangerousFromPointer(this.DangerousGetAddress());
5151
this.pointer=default;
5252
returnresult;
5353
}

‎tests/test_constructors.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""Test CLR class constructor support."""
44

55
importpytest
6+
importsys
67

78
importSystem
89

@@ -71,6 +72,18 @@ def test_default_constructor_fallback():
7172
ob=DefaultConstructorMatching("2")
7273

7374

75+
deftest_constructor_leak():
76+
fromSystemimportUri
77+
fromPython.RuntimeimportRuntime
78+
79+
uri=Uri("http://www.python.org")
80+
Runtime.TryCollectingGarbage(2)
81+
ref_count=sys.getrefcount(uri)
82+
83+
assertref_count==1
84+
85+
86+
7487
deftest_string_constructor():
7588
fromSystemimportString,Char,Array
7689

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp