Who knows somefunction?

Marco Mariani marco at sferacarta.com
Thu Sep 26 18:17:14 EDT 2002


On Thu, Sep 26, 2002 at 11:57:03PM +0200, Gregor Lingl wrote:

> How did you understand my question?
> (Errors should never pass silently)
> Gregor

Yeah, it's useless and a bad idea.

However, let's try:

------------------------------


// Pointer.c

#include <Python.h>
#include <ctype.h>

PyObject* pointer(PyObject* self, PyObject* args) {
        PyObject* p;

        if (!(PyArg_ParseTuple(args,"l",&p)))
                return NULL;

        Py_INCREF(p);
        return p;
}


static PyMethodDef pointer_methods[] = {
        {"pointer",     (PyCFunction) pointer,
                        METH_VARARGS, NULL},
        {NULL,NULL,0}
};


void initpointer(void) {
        Py_InitModule("pointer", pointer_methods);
};


------------------------------

## setup.py

from distutils.core import setup, Extension

module1 = Extension('pointer',
            sources = ['pointer.c'])

setup(name="Pointer",
      version = "0.1",
      author = "Anonymous Coward",
      author_email = "noway at example.com",
      description = "Blah",
      ext_modules = [module1]
      )


------------------------------



Build with "python setup.py build"


Now you can harm yourself. :-)

Tested with python 2.2.1




More information about the Python-list mailing list