Bad argument to internal function when calling method

Discussion in 'Python' started by SkyRanger, Jan 5, 2006.

  1. SkyRanger

    SkyRanger Guest

    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',[@Strs])=-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???
     
    SkyRanger, Jan 5, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Newgene
    Replies:
    1
    Views:
    437
    Newgene
    Jan 13, 2005
  2. robert
    Replies:
    2
    Views:
    428
    robert
    May 16, 2006
  3. S?ren Gammelmark
    Replies:
    1
    Views:
    1,930
    Eric Sosman
    Jan 7, 2005
  4. Reckoner
    Replies:
    11
    Views:
    718
    Steven D'Aprano
    Jan 19, 2009
  5. rantingrick
    Replies:
    44
    Views:
    1,250
    Peter Pearson
    Jul 13, 2010
Loading...

Share This Page