Marshal Embedded Commands
Verfasst: Samstag 13. September 2008, 01:21
Hi!
Ich habe eine Frage, und zwar habe ich eine PYC Datei die ich auf meinem System kompiliert habe. Jedoch stürzt Windows immer beim Aufruf von PyMarshal_ReadObjectFromFile(FILE* p) ab.
Hat damit evtl. jemand Erfahrung.
Auf Mac läuft alles bestens und ohne Probleme.
Ich danke euch. P.S. Das Problem besteht bei Windows 32, und 64.
Cu
Ich habe eine Frage, und zwar habe ich eine PYC Datei die ich auf meinem System kompiliert habe. Jedoch stürzt Windows immer beim Aufruf von PyMarshal_ReadObjectFromFile(FILE* p) ab.
Hat damit evtl. jemand Erfahrung.
Code: Alles auswählen
static FILE *check_compiled_module (char * cpathname)
{
FILE *fp;
long magic;
long pyc_mtime;
fp = fopen (cpathname, "rb");
if (fp == NULL)
return NULL;
magic = PyMarshal_ReadLongFromFile (fp);
if (magic != PyImport_GetMagicNumber())
{
fclose(fp);
return NULL;
}
pyc_mtime = PyMarshal_ReadLongFromFile (fp);
return fp;
}
int main(){
PyObject *main, *maindict, *result, *error; PyCodeObject *code;
Py_Initialize();
FILE * fp;
long mtime;
main = PyImport_AddModule ("__main__");
if (!main)
return false;
maindict = PyModule_GetDict (main);
if ((fp = check_compiled_module ("C:/test.pyc")))
{
code = (PyCodeObject *)PyMarshal_ReadObjectFromFile (fp);
if (! code)
return false;
}
result = PyEval_EvalCode (code, maindict, maindict);
Py_DECREF (code);
Py_XDECREF (result);
if ((error = PyErr_Occurred()))
if (error != PyExc_SystemExit)
PyErr_Print();
Py_Finalize();
return true;
}
Auf Mac läuft alles bestens und ohne Probleme.
Ich danke euch. P.S. Das Problem besteht bei Windows 32, und 64.
Cu