开发者

Python3.2 runtime error with custom defined global function

So all of my custom classes and function calls work just fine, but I have a global function that returns a reference to our game object factory so that we can create game objects in a script.

This reference is guaranteed to exist for the life of the program and script so a reference is safe.

Now here is the error I am getting and the code I am using.

Traceback (most recent call last):
  File "testscript.py", line 7, in <module>
    Factory = Globals.GetFactory()
SystemError: Bad call flags in PyCFunction_Call. METH_OLDARGS is no longer suppo
rted!   

     //get factory is my function pointer to above menti开发者_运维知识库oned function
     PyMethodDef globalMethods[] = 
      {
         {"GetFactory", (PyCFunction)GetFactory, METH_VARARGS,
         "Gets the Factory"},
         {NULL, NULL, 0, NULL}
      };

      //define out custom types module
      PyModuleDef def = { PyModuleDef_HEAD_INIT,
        "Globals",
        0, -1, globalMethods, 0, 0, 0, 0 };
      //push back onto module def ( makes a copy and makes it so pointer just doesn't change
      //for the life of the program while python access this data )
      gPyTypeObjects->mCustomeModulesDef.push_back(def);
      //save the modules memory address by placing it in a list also
      PyObject * mod = PyModule_Create(&gPyTypeObjects->mCustomeModulesDef.back());
      ERROR_IF( mod == NULL, "Failed to create custom pyModule Globals" );

      Py_INCREF(mod);
      gPyTypeObjects->mCustomModules.push_back(mod);
      return gPyTypeObjects->mCustomModules.back();
}

I am trying to provide as much material as needed to not leave anything out.

But for the most part I'm sure you only need the error and the PyMethodDef in addition to the PyModuleDef to help me out here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜