[pypy-commit] cffi python3-port: Tests pass on Linux Python 2.6
arigo
noreply at buildbot.pypy.org
Sun Aug 12 17:31:18 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: python3-port
Changeset: r816:9feb2a45bd4d
Date: 2012-08-12 16:21 +0200
http://bitbucket.org/cffi/cffi/changeset/9feb2a45bd4d/
Log: Tests pass on Linux Python 2.6
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -1943,11 +1943,11 @@
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
+ 0, /*nb_coerce*/
+ (unaryfunc)cdata_int, /*nb_int*/
#if PY_MAJOR_VERSION < 3
- 0, /*nb_coerce*/
(unaryfunc)cdata_long, /*nb_long*/
#else
- (unaryfunc)cdata_int, /*nb_int*/
0, /*nb_reserved*/
#endif
(unaryfunc)cdata_float, /*nb_float*/
diff --git a/cffi/backend_ctypes.py b/cffi/backend_ctypes.py
--- a/cffi/backend_ctypes.py
+++ b/cffi/backend_ctypes.py
@@ -5,9 +5,11 @@
if sys.version_info < (3,):
integer_types = (int, long)
bytes = str
+ bytechr = chr
else:
integer_types = (int,)
xrange = range
+ bytechr = lambda num: bytes([num])
class CTypesData(object):
__slots__ = ['__weakref__']
@@ -376,7 +378,7 @@
@classmethod
def _cast_from(cls, source):
source = _cast_source_to_int(source)
- source = chr(source & 0xFF).encode('latin1')
+ source = bytechr(source & 0xFF)
return cls(source)
def __int__(self):
return ord(self._value)
diff --git a/cffi/vengine_cpy.py b/cffi/vengine_cpy.py
--- a/cffi/vengine_cpy.py
+++ b/cffi/vengine_cpy.py
@@ -1,4 +1,4 @@
-import imp
+import sys, imp
from . import model, ffiplatform
More information about the pypy-commit
mailing list