[pypy-commit] cffi python3-port: Python 2.x compat

arigo noreply at buildbot.pypy.org
Sun Aug 12 19:46:23 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: python3-port
Changeset: r825:78752b181d50
Date: 2012-08-12 19:45 +0200
http://bitbucket.org/cffi/cffi/changeset/78752b181d50/

Log:	Python 2.x compat

diff --git a/cffi/vengine_gen.py b/cffi/vengine_gen.py
--- a/cffi/vengine_gen.py
+++ b/cffi/vengine_gen.py
@@ -377,8 +377,10 @@
             function = module.load_function(BFunc, funcname)
             p = self.ffi.new("char[]", 256)
             if function(p) < 0:
-                raise ffiplatform.VerificationError(
-                    str(self.ffi.string(p), 'utf-8'))
+                error = self.ffi.string(p)
+                if sys.version_info >= (3,):
+                    error = str(error, 'utf-8')
+                raise ffiplatform.VerificationError(error)
 
     def _loaded_gen_enum(self, tp, name, module, library):
         for enumerator, enumvalue in zip(tp.enumerators, tp.enumvalues):


More information about the pypy-commit mailing list