summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPrashanth Pai <ppai@redhat.com>2015-07-13 12:03:25 +0530
committerPrashanth Pai <ppai@redhat.com>2015-07-13 18:34:44 +0530
commitc9fedc64081e1504a1bbf88be5a5dcfb9fff3652 (patch)
tree2d056d15e8ae761311f5baefca7350452aa5ee22
parent1ec40d0753e7d5185a7fc810df33370330fc6f90 (diff)
Backport ctypes.c_ssize_t support to py26
ctypes.c_ssize_t was introduced in Python 2.7 This made libgfapi-python bindings unusable in RHEL 6 which only contains Python 2.6 Change-Id: I401697004d7eecb110b8c92a3ddd27397e3d8785 Signed-off-by: Prashanth Pai <ppai@redhat.com>
-rwxr-xr-xgluster/api.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/gluster/api.py b/gluster/api.py
index 62135c5..d2a0840 100755
--- a/gluster/api.py
+++ b/gluster/api.py
@@ -11,6 +11,7 @@
import ctypes
from ctypes.util import find_library
+from ctypes import sizeof
# LD_LIBRARY_PATH is not looked up by ctypes.util.find_library()
@@ -41,6 +42,18 @@ except OSError:
raise ImportError("ctypes.CDLL() cannot load {0}. You might want to set "
"LD_LIBRARY_PATH env variable".format(so_file_name))
+# c_ssize_t was only added in py27. Manually backporting it here for py26
+try:
+ import ctypes.c_ssize_t
+except ImportError:
+ if sizeof(ctypes.c_uint) == sizeof(ctypes.c_void_p):
+ setattr(ctypes, 'c_ssize_t', ctypes.c_int)
+ elif sizeof(ctypes.c_ulong) == sizeof(ctypes.c_void_p):
+ setattr(ctypes, 'c_ssize_t', ctypes.c_long)
+ elif sizeof(ctypes.c_ulonglong) == sizeof(ctypes.c_void_p):
+ setattr(ctypes, 'c_ssize_t', ctypes.c_longlong)
+
+
# Wow, the Linux kernel folks really play nasty games with this structure. If
# you look at the man page for stat(2) and then at this definition you'll note
# two discrepancies. First, we seem to have st_nlink and st_mode reversed. In