Hi!
I make class extension from Delphi, but i have problem. Here my code:

//====================================================================
{pyClassMethod}

function pyClassMethod( self, args : PPyObject ) : PPyObject; cdecl;
var
  Strs : PChar;
begin
  if PyArg_ParseTuple(args, 's',[EMAIL PROTECTED])=-1 then
    Result:=nil
  else
  begin
    ShowMessage(Strs);
  end;
    Py_INCREF(Py_None);
    Result:=Py_None
end;

var
  Classname, Claass : PPyObject;
  MyFunc,MyMeth :PPyObject;


  Classname:= PyString_FromString('class_test');
  Claass:= PyClass_New(nil, Python.PyScript.GetPyDict, Classname);
  PyDict_SetItemString(Python.PyScript.GetPyDict, 'class_test',
Claass);
  MyMethod.ml_name:='test';
  MyMethod.ml_meth:=pyClassMethod;
  MyMethod.ml_flags:=METH_CLASS;
  MyMethod.ml_doc:='DOC';

  MyFunc:=PyCFunction_New(@MyMethod, nil);
  MyMeth:=PyMethod_New(MyFunc, nil, Claass);
  PyDict_SetItemString(Python.PyScript.GetPyDict, 'test', MyMeth);

Python.PyScript.GetPyDict - just return exists dictionary


Here python code:

        class testcl1(sky3d.class_test):
                def fun(self):
                        print "Hello"
        tst=testcl1()
        tst.fun()
        tst.test("123")

When i run it i get error:

tst.test("123")
SystemError
:
C:\sf\python\dist23\src\Objects\methodobject.c:112: bad argument to
internal function

So error raise in this string:
tst.test("123")

How to remove this error and make this work???

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to