From 853e34087ad8abac7dd6051f70af63a0fac43b75 Mon Sep 17 00:00:00 2001 From: Faizan Rashid Date: Sun, 13 Dec 2015 02:55:16 -0500 Subject: [PATCH] [BUG] [MINOR] Use buffer for specific py versions Fix for Issue 1741 Minor bug where python versions 2.7.x where x < 5 do not support unpacking from memoryview objects. Versions 2.7.5 and above will use memoryview while 2.7 versions below 2.7.5 will use buffer objects. Manual testing was performed on versions 2.7.5 and 2.7.2 to confirm both worked correctly. --- python/flatbuffers/compat.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/flatbuffers/compat.py b/python/flatbuffers/compat.py index 30c504d5e..345e38cbf 100644 --- a/python/flatbuffers/compat.py +++ b/python/flatbuffers/compat.py @@ -4,6 +4,8 @@ import sys PY2 = sys.version_info[0] == 2 PY26 = sys.version_info[0:2] == (2, 6) +PY27 = sys.version_info[0:2] == (2, 7) +PY275 = sys.version_info[0:3] >= (2, 7, 5) PY3 = sys.version_info[0] == 3 PY34 = sys.version_info[0:2] >= (3, 4) @@ -17,7 +19,7 @@ else: string_types = (basestring,) binary_type = str range_func = xrange - if PY26: + if PY26 or (PY27 and not PY275): memoryview_type = buffer struct_bool_decl = "