diff options
| author | Armin Rigo <arigo@tunes.org> | 2015-11-20 15:57:31 +0100 |
|---|---|---|
| committer | Armin Rigo <arigo@tunes.org> | 2015-11-20 15:57:31 +0100 |
| commit | a55d1ad2ced2bbd8e481936271df44ab9b8b99f0 (patch) | |
| tree | 5c582ed54014eb9af36504cbe6ddfc435c4aa7be /c/call_python.c | |
| parent | 98e4f76fe2da26e84b7c02e9a0c32c0a2e7d07a1 (diff) | |
| download | cffi-a55d1ad2ced2bbd8e481936271df44ab9b8b99f0.tar.gz | |
Change the @ffi.def_extern() decorator to not automatically replace the
function with the cdata. You need to get the cdata from the lib
explicitly. This should make it clearer that there is only one cdata,
even if you apply the decorator again.
Diffstat (limited to 'c/call_python.c')
| -rw-r--r-- | c/call_python.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/c/call_python.c b/c/call_python.c index f456d8e..a2da772 100644 --- a/c/call_python.c +++ b/c/call_python.c @@ -43,10 +43,9 @@ static PyObject *_ffi_def_extern_decorator(PyObject *outer_args, PyObject *fn) return NULL; infotuple = prepare_callback_info_tuple(ct, fn, error, onerror, 0); - if (infotuple == NULL) { - Py_DECREF(ct); + Py_DECREF(ct); + if (infotuple == NULL) return NULL; - } /* attach infotuple to reserved1, where it will stay forever unless a new version is attached later */ @@ -55,11 +54,9 @@ static PyObject *_ffi_def_extern_decorator(PyObject *outer_args, PyObject *fn) externpy->reserved1 = (void *)infotuple; Py_XDECREF(x); - /* return a cdata of type function-pointer, equal to the one - obtained by reading 'lib.bar' (see lib_obj.c) */ - x = convert_to_object((char *)&g->size_or_direct_fn, ct); - Py_DECREF(ct); - return x; + /* return the function object unmodified */ + Py_INCREF(fn); + return fn; not_found: PyErr_Format(FFIError, "ffi.def_extern('%s'): no 'extern \"Python\"' " |
