@@ -23,16 +23,16 @@ namespace Python.Runtime
2323 internal class ConstructorBinding : ExtensionType
2424 {
2525 private MaybeType type ; // The managed Type being wrapped in a ClassObject
26- private IntPtr pyTypeHndl ; // The python type tells GetInstHandle which Type to create.
26+ private PyType typeToCreate ; // The python type tells GetInstHandle which Type to create.
2727 private ConstructorBinder ctorBinder ;
2828
2929 [ NonSerialized ]
3030 private IntPtr repr ;
3131
32- public ConstructorBinding ( Type type , IntPtr pyTypeHndl , ConstructorBinder ctorBinder )
32+ public ConstructorBinding ( Type type , PyType typeToCreate , ConstructorBinder ctorBinder )
3333 {
3434 this . type = type ;
35- this . pyTypeHndl = pyTypeHndl ; // steal a type reference
35+ this . typeToCreate = typeToCreate ;
3636 this . ctorBinder = ctorBinder ;
3737 repr = IntPtr . Zero ;
3838 }
@@ -110,7 +110,7 @@ public static IntPtr mp_subscript(IntPtr op, IntPtr key)
110110 {
111111 return Exceptions . RaiseTypeError ( "No match found for constructor signature" ) ;
112112 }
113- var boundCtor = new BoundContructor ( tp , self . pyTypeHndl , self . ctorBinder , ci ) ;
113+ var boundCtor = new BoundContructor ( tp , self . typeToCreate , self . ctorBinder , ci ) ;
114114
115115 return boundCtor . pyHandle ;
116116 }
@@ -169,7 +169,7 @@ public static int tp_clear(IntPtr ob)
169169 public static int tp_traverse ( IntPtr ob , IntPtr visit , IntPtr arg )
170170 {
171171 var self = ( ConstructorBinding ) GetManagedObject ( ob ) ;
172- int res = PyVisit ( self . pyTypeHndl , visit , arg ) ;
172+ int res = PyVisit ( self . typeToCreate . Handle , visit , arg ) ;
173173 if ( res != 0 ) return res ;
174174
175175 res = PyVisit ( self . repr , visit , arg ) ;
@@ -190,15 +190,15 @@ public static int tp_traverse(IntPtr ob, IntPtr visit, IntPtr arg)
190190 internal class BoundContructor : ExtensionType
191191 {
192192 private Type type ; // The managed Type being wrapped in a ClassObject
193- private IntPtr pyTypeHndl ; // The python type tells GetInstHandle which Type to create.
193+ private PyType typeToCreate ; // The python type tells GetInstHandle which Type to create.
194194 private ConstructorBinder ctorBinder ;
195195 private ConstructorInfo ctorInfo ;
196196 private IntPtr repr ;
197197
198- public BoundContructor ( Type type , IntPtr pyTypeHndl , ConstructorBinder ctorBinder , ConstructorInfo ci )
198+ public BoundContructor ( Type type , PyType typeToCreate , ConstructorBinder ctorBinder , ConstructorInfo ci )
199199 {
200200 this . type = type ;
201- this . pyTypeHndl = pyTypeHndl ; // steal a type reference
201+ this . typeToCreate = typeToCreate ;
202202 this . ctorBinder = ctorBinder ;
203203 ctorInfo = ci ;
204204 repr = IntPtr . Zero ;
@@ -229,7 +229,7 @@ public static IntPtr tp_call(IntPtr op, IntPtr args, IntPtr kw)
229229 }
230230 // Instantiate the python object that wraps the result of the method call
231231 // and return the PyObject* to it.
232- return CLRObject . GetInstHandle ( obj , self . pyTypeHndl ) ;
232+ return CLRObject . GetInstHandle ( obj , self . typeToCreate . Reference ) . DangerousMoveToPointer ( ) ;
233233 }
234234
235235 /// <summary>
@@ -272,7 +272,7 @@ public static int tp_clear(IntPtr ob)
272272 public static int tp_traverse ( IntPtr ob , IntPtr visit , IntPtr arg )
273273 {
274274 var self = ( BoundContructor ) GetManagedObject ( ob ) ;
275- int res = PyVisit ( self . pyTypeHndl , visit , arg ) ;
275+ int res = PyVisit ( self . typeToCreate . Handle , visit , arg ) ;
276276 if ( res != 0 ) return res ;
277277
278278 res = PyVisit ( self . repr , visit , arg ) ;
0 commit comments