- Notifications
You must be signed in to change notification settings - Fork750
Closed
Description
Environment
- Pythonnet version: 2.3.0
- Python version: 3.6-32
- Operating System: Windows 10
Details
- Getting a
MethodBinding
for a generic method results in the reference count being too high, so thetp_dealloc
method on theMethodBinding
never gets called, even when theMethodBinding
goes out of scope.
namespacePlainOldNamespace{publicclassPlainOldClass{publicvoidNonGenericMethod(){}publicvoidGenericMethod<T>(){}}}
importclr,sysclr.AddReference("PlainOldAssembly")fromPlainOldNamespaceimportPlainOldClasspoc=PlainOldClass()sys.getrefcount(poc.NonGenericMethod)# 1sys.getrefcount(poc.GenericMethod[clr.System.Double])# 2 - should be 1
I think this could be down to a bug in MethodBinding.cs. This line looks suspicious. Why should the reference count get incremented here?
https://github.com/pythonnet/pythonnet/blob/master/src/runtime/methodbinding.cs#L59
Metadata
Metadata
Assignees
Labels
No labels