Bad argument to internal function when calling method

S

SkyRanger

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???
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top