@@ -31,35 +31,19 @@ public MethodWrapper(Type type, string name) {
3131
3232 IntPtr fp = Interop . GetThunk ( type . GetMethod ( name ) ) ;
3333
34- // XXX - here we create a Python string object, then take the
35- // char * of the internal string to pass to our methoddef
36- // structure. Its a hack, and the name is leaked!
37- #if ( PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 )
38- IntPtr ps = Runtime . PyBytes_FromString ( name ) ;
39- IntPtr sp = Runtime . PyBytes_AS_STRING ( ps ) ;
40- #else
41- IntPtr ps = Runtime . PyString_FromString ( name ) ;
42- IntPtr sp = Runtime . PyString_AS_STRING ( ps ) ;
43- #endif
44-
4534 // Allocate and initialize a PyMethodDef structure to represent
4635 // the managed method, then create a PyCFunction.
4736
4837 mdef = Runtime . PyMem_Malloc ( 4 * IntPtr . Size ) ;
49- Marshal . WriteIntPtr ( mdef , sp ) ;
38+ Marshal . WriteIntPtr ( mdef , Marshal . StringToHGlobalAnsi ( name ) ) ;
5039 Marshal . WriteIntPtr ( mdef , ( 1 * IntPtr . Size ) , fp ) ;
51- Marshal . WriteIntPtr ( mdef , ( 2 * IntPtr . Size ) , ( IntPtr ) 0x0003 ) ; // METH_VARARGS | METH_KEYWORDS
40+ Marshal . WriteInt32 ( mdef , ( 2 * IntPtr . Size ) , 0x0003 ) ; // METH_VARARGS | METH_KEYWORDS
5241 Marshal . WriteIntPtr ( mdef , ( 3 * IntPtr . Size ) , IntPtr . Zero ) ;
5342 ptr = Runtime . PyCFunction_NewEx ( mdef , IntPtr . Zero , IntPtr . Zero ) ;
5443 }
5544
5645 public IntPtr Call ( IntPtr args , IntPtr kw ) {
5746 return Runtime . PyCFunction_Call ( ptr , args , kw ) ;
5847 }
59-
60-
6148 }
62-
63-
64- }
65-
49+ }
0 commit comments