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

Exception in finalizer of custom encoder #1256

Open
@danabr

Description

@danabr

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp