FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

handle is not inialized crash on `clr.GetClrType(System.__class__)` · Issue #606 · pythonnet/pythonnet · GitHub

Repository navigation

handle is not inialized crash on clr.GetClrType(System.__class__) #606

Closed

Description

Python 3.5, 64-bit, Windows 10, pythonnet master

clr.GetClrType(System.__class__)
Unhandled Exception: System.InvalidOperationException: Handle is not initialized.
   at System.Runtime.InteropServices.GCHandle.FromIntPtr(IntPtr value)
   at Python.Runtime.ManagedType.GetManagedObject(IntPtr ob)
   at Python.Runtime.Converter.ToManagedValue(IntPtr value, Type obType, Object& result, Boolean setError)
   at Python.Runtime.Converter.ToManaged(IntPtr value, Type type, Object& result, Boolean setError)
   at Python.Runtime.MethodBinder.Bind(IntPtr inst, IntPtr args, IntPtr kw, MethodBase info, MethodInfo[] methodinfo)
   at Python.Runtime.MethodBinder.Invoke(IntPtr inst, IntPtr args, IntPtr kw, MethodBase info, MethodInfo[] methodinfo)
   at Python.Runtime.MethodObject.Invoke(IntPtr target, IntPtr args, IntPtr kw, MethodBase info)
   at Python.Runtime.MethodObject.Invoke(IntPtr inst, IntPtr args, IntPtr kw)
   at Python.Runtime.ModuleFunctionObject.tp_call(IntPtr ob, IntPtr args, IntPtr kw)

Activity

  1. den-run-ai commented on Jan 28, 2018

    ContributorAuthor

    The reason why I encountered this error is when iterating over System members to find all built-in structs:

    structs=list()
    for i,_type in enumerate(dir(System)):
        print((i, _type), end=", ")
        try:
            t=getattr(System, _type)
        except Exception as e:
            print('cannot get attribute {0}'.format(_type))
        else:
            try:
                tt=clr.GetClrType(t)
            except:
                pass
            else:
                if tt.IsValueType and (not tt.IsEnum):
                    print()
                    print()
                    print(tt)
                    print()
                    structs.append((i, _type, tt))
  2. den-run-ai commented on Jan 28, 2018

    ContributorAuthor

    The fixed behavior is exception instead of crashing python interpreter:

    ---------------------------------------------------------------------------
    TypeError                                 Traceback (most recent call last)
    <ipython-input-6-ef0439a47067> in <module>()
    ----> 1 clr.GetClrType(System.__class__)
    
    TypeError: No method matches given arguments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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


      Back | FazBrowse Home | New Git URL