C++: Py_CompileString crash

KillSwitch gu.yakahughes at gmail.com
Mon Oct 26 17:29:29 CET 2009

I run this code in VC++:

#include <Python.h>
#include <string.h>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])

	const char* filename = "asdf.py";

	const char* str = "print('lol')";

	Py_CompileString(str, filename, 0);

	return 0;

On running, it immediately crashes.

I use PyRun_SimpleString and other high level stuff from the API with
no problem, but Py_CompileString is not working. I'm probably using it

Any help is appreciated.

More information about the Python-list mailing list