summaryrefslogtreecommitdiff
path: root/cffi/vengine_cpy.py
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2013-11-10 13:20:27 +0100
committerArmin Rigo <arigo@tunes.org>2013-11-10 13:20:27 +0100
commit42dcdd91fc47bf7a62d2c5102c93ab8b1fbe19f3 (patch)
treee5633930b924d39418bbef82cb54ddba3315c540 /cffi/vengine_cpy.py
parent4370664a6f2dad76a51c66b99caf00a8d514e618 (diff)
downloadcffi-42dcdd91fc47bf7a62d2c5102c93ab8b1fbe19f3.tar.gz
Issue #116: give out a warning when we're doing that
Diffstat (limited to 'cffi/vengine_cpy.py')
-rw-r--r--cffi/vengine_cpy.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/cffi/vengine_cpy.py b/cffi/vengine_cpy.py
index b7784aa..83e3a55 100644
--- a/cffi/vengine_cpy.py
+++ b/cffi/vengine_cpy.py
@@ -160,7 +160,10 @@ class VCPythonEngine(object):
def __dir__(self):
return FFILibrary._cffi_dir + list(self.__dict__)
library = FFILibrary()
- module._cffi_setup(lst, ffiplatform.VerificationError, library)
+ if module._cffi_setup(lst, ffiplatform.VerificationError, library):
+ import warnings
+ warnings.warn("reimporting %r might overwrite older definitions"
+ % (self.verifier.get_module_name()))
#
# finally, call the loaded_cpy_xxx() functions. This will perform
# the final adjustments, like copying the Python->C wrapper
@@ -754,12 +757,9 @@ class VCPythonEngine(object):
def _generate_setup_custom(self):
prnt = self._prnt
- prnt('static PyObject *_cffi_setup_custom(PyObject *lib)')
+ prnt('static int _cffi_setup_custom(PyObject *lib)')
prnt('{')
- prnt(' if (%s < 0)' % self._chained_list_constants[True])
- prnt(' return NULL;')
- prnt(' Py_INCREF(Py_None);')
- prnt(' return Py_None;')
+ prnt(' return %s;' % self._chained_list_constants[True])
prnt('}')
cffimod_header = r'''
@@ -877,17 +877,20 @@ typedef struct _ctypedescr CTypeDescrObject;
static void *_cffi_exports[_CFFI_NUM_EXPORTS];
static PyObject *_cffi_types, *_cffi_VerificationError;
-static PyObject *_cffi_setup_custom(PyObject *lib); /* forward */
+static int _cffi_setup_custom(PyObject *lib); /* forward */
static PyObject *_cffi_setup(PyObject *self, PyObject *args)
{
PyObject *library;
+ int was_alive = (_cffi_types != NULL);
if (!PyArg_ParseTuple(args, "OOO", &_cffi_types, &_cffi_VerificationError,
&library))
return NULL;
Py_INCREF(_cffi_types);
Py_INCREF(_cffi_VerificationError);
- return _cffi_setup_custom(library);
+ if (_cffi_setup_custom(library) < 0)
+ return NULL;
+ return PyBool_FromLong(was_alive);
}
static void _cffi_init(void)