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

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions 18 src/embed_tests/pyinitialize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ public static void LoadSpecificArgs()
}
}

// regression test for https://github.com/pythonnet/pythonnet/issues/1561
[Test]
public void ImportClassShutdownRefcount()
{
PythonEngine.Initialize();

PyObject ns = Py.Import(typeof(ImportClassShutdownRefcountClass).Namespace);
PyObject cls = ns.GetAttr(nameof(ImportClassShutdownRefcountClass));
ns.Dispose();

Assert.Less(cls.Refcount, 256);

PythonEngine.Shutdown();
Assert.Greater(cls.Refcount, 0);
}

/// <summary>
/// Failing test demonstrating current issue with OverflowException (#376)
/// and ArgumentException issue after that one is fixed.
Expand Down Expand Up @@ -182,4 +198,6 @@ public static void TestRunExitFuncs()
Assert.True(called);
}
}

public class ImportClassShutdownRefcountClass { }
}
1 change: 0 additions & 1 deletion 1 src/runtime/classmanager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ internal static void DisposePythonWrappersForClrTypes()
// since others may still referencing it.
cls.CallTypeTraverse(TraverseTypeClear, visitedPtr);
cls.CallTypeClear();
cls.DecrRefCount();
}
}
finally
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.