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

Commit8658322

Browse files
committed
removed code testing possiblity to dispose objects after domain restart
1 parent913e429 commit8658322

File tree

1 file changed

+0
-110
lines changed

1 file changed

+0
-110
lines changed

‎src/embed_tests/TestDomainReload.cs

Lines changed: 0 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -179,116 +179,6 @@ public static void CrossDomainObject()
179179

180180
#endregion
181181

182-
#region Tempary tests
183-
184-
// https://github.com/pythonnet/pythonnet/pull/1074#issuecomment-596139665
185-
[Test]
186-
publicvoidCrossReleaseBuiltinType()
187-
{
188-
voidExecTest()
189-
{
190-
try
191-
{
192-
PythonEngine.Initialize();
193-
varnumRef=CreateNumReference();
194-
Assert.True(numRef.IsAlive);
195-
PythonEngine.Shutdown();// <- "run" 1 ends
196-
PythonEngine.Initialize();// <- "run" 2 starts
197-
198-
GC.Collect();
199-
GC.WaitForPendingFinalizers();// <- this will put former `num` into Finalizer queue
200-
Finalizer.Instance.Collect();
201-
// ^- this will call PyObject.Dispose, which will call XDecref on `num.Handle`,
202-
// but Python interpreter from "run" 1 is long gone, so it will corrupt memory instead.
203-
Assert.False(numRef.IsAlive);
204-
}
205-
finally
206-
{
207-
PythonEngine.Shutdown();
208-
}
209-
}
210-
211-
varerrorArgs=newList<Finalizer.ErrorArgs>();
212-
voidErrorHandler(objectsender,Finalizer.ErrorArgse)
213-
{
214-
errorArgs.Add(e);
215-
}
216-
Finalizer.Instance.ErrorHandler+=ErrorHandler;
217-
try
218-
{
219-
for(inti=0;i<10;i++)
220-
{
221-
ExecTest();
222-
}
223-
}
224-
finally
225-
{
226-
Finalizer.Instance.ErrorHandler-=ErrorHandler;
227-
}
228-
Assert.AreEqual(errorArgs.Count,0);
229-
}
230-
231-
[Test]
232-
publicvoidCrossReleaseCustomType()
233-
{
234-
voidExecTest()
235-
{
236-
try
237-
{
238-
PythonEngine.Initialize();
239-
varobjRef=CreateConcreateObject();
240-
Assert.True(objRef.IsAlive);
241-
PythonEngine.Shutdown();// <- "run" 1 ends
242-
PythonEngine.Initialize();// <- "run" 2 starts
243-
GC.Collect();
244-
GC.WaitForPendingFinalizers();
245-
Finalizer.Instance.Collect();
246-
Assert.False(objRef.IsAlive);
247-
}
248-
finally
249-
{
250-
PythonEngine.Shutdown();
251-
}
252-
}
253-
254-
varerrorArgs=newList<Finalizer.ErrorArgs>();
255-
voidErrorHandler(objectsender,Finalizer.ErrorArgse)
256-
{
257-
errorArgs.Add(e);
258-
}
259-
Finalizer.Instance.ErrorHandler+=ErrorHandler;
260-
try
261-
{
262-
for(inti=0;i<10;i++)
263-
{
264-
ExecTest();
265-
}
266-
}
267-
finally
268-
{
269-
Finalizer.Instance.ErrorHandler-=ErrorHandler;
270-
}
271-
Assert.AreEqual(errorArgs.Count,0);
272-
}
273-
274-
privatestaticWeakReferenceCreateNumReference()
275-
{
276-
varnum=3216757418.ToPython();
277-
Assert.AreEqual(num.Refcount,1);
278-
WeakReferencenumRef=newWeakReference(num,false);
279-
returnnumRef;
280-
}
281-
282-
privatestaticWeakReferenceCreateConcreateObject()
283-
{
284-
varobj=newDomain.MyClass().ToPython();
285-
Assert.AreEqual(obj.Refcount,1);
286-
WeakReferencenumRef=newWeakReference(obj,false);
287-
returnnumRef;
288-
}
289-
290-
#endregion Tempary tests
291-
292182
/// <summary>
293183
/// This is a magic incantation required to run code in an application
294184
/// domain other than the current one.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp