- Notifications
You must be signed in to change notification settings - Fork749
Open
Description
Environment
- Pythonnet version: master
- Python version: 3.7
- Operating System: Windows 10
Details
I am using a custom encoder defined in Python to work around the conversion of IList to Python lists (see#963 (comment)):
# Prevent Python.NET from converting IList to Python listsfromPython.RuntimeimportPyObjectConversionsfromPython.Runtime.CodecsimportRawProxyEncoderclassListAsRawEncoder(RawProxyEncoder):__namespace__='Python.Runtime.Codecs'defCanEncode(self,clr_type):returnclr_type.Name=='IList`1'andclr_type.Namespace=='System.Collections.Generic'list_encoder=ListAsRawEncoder()PyObjectConversions.RegisterEncoder(list_encoder)
This works fine until I have calledPython.Runtime.PythonEngine.Shutdown
, and GC kicks in. Then there is this exception:
Unhandled exceptionException thrown:System.InvalidOperationException: Handle is not initialized. at System.Runtime.InteropServices.GCHandle.Free() at Python.Runtime.PythonDerivedType.Finalize(IPythonDerivedType obj) at Python.Runtime.Codecs.ListAsRawEncoder.Finalize()
The crash started happening after#958 was merged.
Metadata
Metadata
Assignees
Labels
No labels