Skip to content

Commit 9333d77

Browse files
authored
Merge pull request #607 from pythonnet/getclrtype
fix for "handle is not inialized" crash on `clr.GetClrType(System.__class__)`
2 parents 32ec24c + 19ec822 commit 9333d77

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
2828
- Fixed conversion of 'float' and 'double' values (#486)
2929
- Fixed 'clrmethod' for python 2 (#492)
3030
- Fixed double calling of constructor when deriving from .NET class (#495)
31+
- Fixed `clr.GetClrType` when iterating over `System` members (#607)
3132

3233

3334
## [2.3.0][] - 2017-03-11

src/runtime/managedtype.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Runtime.InteropServices;
33

44
namespace Python.Runtime
@@ -34,6 +34,10 @@ internal static ManagedType GetManagedObject(IntPtr ob)
3434
IntPtr op = tp == ob
3535
? Marshal.ReadIntPtr(tp, TypeOffset.magic())
3636
: Marshal.ReadIntPtr(ob, ObjectOffset.magic(ob));
37+
if (op == IntPtr.Zero)
38+
{
39+
return null;
40+
}
3741
var gc = (GCHandle)op;
3842
return (ManagedType)gc.Target;
3943
}

0 commit comments

Comments
 (0)