[pypy-commit] cffi default: Issue #116: give out a warning when we're doing that
arigo
noreply at buildbot.pypy.org
Sun Nov 10 13:20:35 CET 2013
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r1411:861bff9ef031
Date: 2013-11-10 13:20 +0100
http://bitbucket.org/cffi/cffi/changeset/861bff9ef031/
Log: Issue #116: give out a warning when we're doing that
diff --git a/cffi/vengine_cpy.py b/cffi/vengine_cpy.py
--- a/cffi/vengine_cpy.py
+++ b/cffi/vengine_cpy.py
@@ -160,7 +160,10 @@
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 @@
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 @@
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)
More information about the pypy-commit
mailing list