-
-
Save niwinz/7420905 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Python.h> | |
/* | |
* Usage | |
$ python | |
Python 2.7.3 |Anaconda 1.4.0 (64-bit)| (default, Feb 25 2013, 18:46:31) | |
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2 | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> import evil | |
>>> True | |
False | |
>>> False | |
True | |
>>> 2+2 | |
42 | |
*/ | |
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