diff options
author | Armin Rigo <arigo@tunes.org> | 2012-08-12 16:21:41 +0200 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2012-08-12 16:21:41 +0200 |
commit | 6937ef007650ca5ceccc8118ca845976314d5222 (patch) | |
tree | a846ed986ef36e5b5342e906584ff31340aa8845 /cffi/backend_ctypes.py | |
parent | 86a9c916f3e459d5b8a6c6ae7155ceb8670569a1 (diff) | |
download | cffi-6937ef007650ca5ceccc8118ca845976314d5222.tar.gz |
Tests pass on Linux Python 2.6
Diffstat (limited to 'cffi/backend_ctypes.py')
-rw-r--r-- | cffi/backend_ctypes.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/cffi/backend_ctypes.py b/cffi/backend_ctypes.py index 5ee451d..f7944a4 100644 --- a/cffi/backend_ctypes.py +++ b/cffi/backend_ctypes.py @@ -5,9 +5,11 @@ import sys 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 @@ class CTypesBackend(object): @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) |