[pypy-commit] cffi python3-port: Fixes fixes
arigo
noreply at buildbot.pypy.org
Sun Aug 12 19:46:22 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: python3-port
Changeset: r824:910586283694
Date: 2012-08-12 19:41 +0200
http://bitbucket.org/cffi/cffi/changeset/910586283694/
Log: Fixes fixes
diff --git a/cffi/vengine_gen.py b/cffi/vengine_gen.py
--- a/cffi/vengine_gen.py
+++ b/cffi/vengine_gen.py
@@ -21,7 +21,7 @@
pass # not needed in the generic engine
def _prnt(self, what=''):
- print >> self._f, what
+ self._f.write(what + '\n')
def write_source_to_f(self):
prnt = self._prnt
@@ -60,7 +60,7 @@
return library
def _generate(self, step_name):
- for name, tp in self.ffi._parser._declarations.iteritems():
+ for name, tp in self.ffi._parser._declarations.items():
kind, realname = name.split(' ', 1)
try:
method = getattr(self, '_generate_gen_%s_%s' % (kind,
@@ -71,7 +71,7 @@
method(tp, realname)
def _load(self, module, step_name, **kwds):
- for name, tp in self.ffi._parser._declarations.iteritems():
+ for name, tp in self.ffi._parser._declarations.items():
kind, realname = name.split(' ', 1)
method = getattr(self, '_%s_gen_%s' % (step_name, kind))
method(tp, realname, module, **kwds)
@@ -377,7 +377,8 @@
function = module.load_function(BFunc, funcname)
p = self.ffi.new("char[]", 256)
if function(p) < 0:
- raise ffiplatform.VerificationError(self.ffi.string(p))
+ raise ffiplatform.VerificationError(
+ str(self.ffi.string(p), 'utf-8'))
def _loaded_gen_enum(self, tp, name, module, library):
for enumerator, enumvalue in zip(tp.enumerators, tp.enumvalues):
diff --git a/cffi/verifier.py b/cffi/verifier.py
--- a/cffi/verifier.py
+++ b/cffi/verifier.py
@@ -62,7 +62,9 @@
def get_module_name(self):
basename = os.path.basename(self.modulefilename)
- return basename.rsplit('.', 1)[0]
+ # kill both the .so extension and the other .'s, as introduced
+ # by Python 3: 'basename.cpython-33m.so'
+ return basename.split('.', 1)[0]
def get_extension(self):
if self._status == 'init':
diff --git a/testing/test_verify.py b/testing/test_verify.py
--- a/testing/test_verify.py
+++ b/testing/test_verify.py
@@ -134,7 +134,7 @@
def test_nonstandard_integer_types():
ffi = FFI()
lst = ffi._backend.nonstandard_integer_types().items()
- lst.sort()
+ lst = sorted(lst)
verify_lines = []
for key, value in lst:
ffi.cdef("static const int expected_%s;" % key)
diff --git a/testing/test_zdistutils.py b/testing/test_zdistutils.py
--- a/testing/test_zdistutils.py
+++ b/testing/test_zdistutils.py
@@ -142,7 +142,7 @@
assert lib.sin(12.3) == math.sin(12.3)
v = ffi.verifier
ext = v.get_extension()
- assert str(ext.__class__) == 'distutils.extension.Extension'
+ assert 'distutils.extension.Extension' in str(ext.__class__)
assert ext.sources == [v.sourcefilename]
assert ext.name == v.get_module_name()
assert ext.define_macros == [('TEST_EXTENSION_OBJECT', '1')]
More information about the pypy-commit
mailing list