Commits

Armin Rigo  committed 9105862

Fixes fixes

  • Participants
  • Parent commits f14a95a
  • Branches python3-port

Comments (0)

Files changed (4)

File cffi/vengine_gen.py

         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
         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,
             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)
             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):

File cffi/verifier.py

 
     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':

File testing/test_verify.py

 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)

File testing/test_zdistutils.py

         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')]