From 16f05e51d894f230787af0e7f64ac29514ab46fd Mon Sep 17 00:00:00 2001 From: Denis Akhiyarov Date: Sun, 28 Jan 2018 12:11:13 -0600 Subject: [PATCH 1/2] fix for "handle is not inialized" crash on `clr.GetClrType(System.__class__)` --- src/runtime/managedtype.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/runtime/managedtype.cs b/src/runtime/managedtype.cs index 562b2e5f8..3191da949 100644 --- a/src/runtime/managedtype.cs +++ b/src/runtime/managedtype.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Runtime.InteropServices; namespace Python.Runtime @@ -34,6 +34,10 @@ internal static ManagedType GetManagedObject(IntPtr ob) IntPtr op = tp == ob ? Marshal.ReadIntPtr(tp, TypeOffset.magic()) : Marshal.ReadIntPtr(ob, ObjectOffset.magic(ob)); + if (op == IntPtr.Zero) + { + return null; + } var gc = (GCHandle)op; return (ManagedType)gc.Target; } From 19ec8224795cd7385de65fb5c7dc2cb81a85927e Mon Sep 17 00:00:00 2001 From: Denis Akhiyarov Date: Sun, 28 Jan 2018 12:21:27 -0600 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d408a8d1..380c6f6d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][]. - Fixed conversion of 'float' and 'double' values (#486) - Fixed 'clrmethod' for python 2 (#492) - Fixed double calling of constructor when deriving from .NET class (#495) +- Fixed `clr.GetClrType` when iterating over `System` members (#607) ## [2.3.0][] - 2017-03-11