Author: Armin Rigo <[email protected]>
Branch:
Changeset: r2842:f06bbfeeb823
Date: 2016-12-25 10:02 +0100
http://bitbucket.org/cffi/cffi/changeset/f06bbfeeb823/
Log: Improve the error in case of version mismatch
diff --git a/cffi/api.py b/cffi/api.py
--- a/cffi/api.py
+++ b/cffi/api.py
@@ -55,8 +55,17 @@
# _cffi_backend.so compiled.
import _cffi_backend as backend
from . import __version__
- assert backend.__version__ == __version__, \
- "version mismatch, %s != %s" % (backend.__version__,
__version__)
+ if backend.__version__ != __version__:
+ # bad version! Try to be as explicit as possible.
+ if hasattr(backend, '__file__'):
+ # CPython
+ raise Exception("Version mismatch: this is the 'cffi'
package version %s, located in %r. When we import the top-level
'_cffi_backend' extension module, we get version %s, located in %r. The two
versions should be equal; check your installation." % (
+ __version__, __file__,
+ backend.__version__, backend.__file__))
+ else:
+ # PyPy
+ raise Exception("Version mismatch: this is the 'cffi'
package version %s, located in %r. This interpreter comes with a built-in
'_cffi_backend' module, which is version %s. The two versions should be equal;
check your installation." % (
+ __version__, __file__, backend.__version__))
# (If you insist you can also try to pass the option
# 'backend=backend_ctypes.CTypesBackend()', but don't
# rely on it! It's probably not going to work well.)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit