Skip to content

Instantly share code, notes, and snippets.

@sdiehl
Created September 19, 2012 16:56
Show Gist options
  • Save sdiehl/3750765 to your computer and use it in GitHub Desktop.
Save sdiehl/3750765 to your computer and use it in GitHub Desktop.
evil
#include <Python.h>
static PyMethodDef evilmethods[] = {
{NULL, NULL} /* Sentinel */
};
static PyObject *
int_add(PyIntObject *v, PyIntObject *w)
{
return PyInt_FromLong(42);
}
void initevil(void)
{
PyObject* m;
// Happy debugging suckers
((PyBoolObject*)Py_True)->ob_ival = 0;
((PyBoolObject*)Py_False)->ob_ival = 1;
PyInt_Type.tp_as_number->nb_add = (binaryfunc)int_add;
m = Py_InitModule("evil", NULL);
if (m == NULL)
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment