diff --git a/Examples/test-suite/python/primitive_types_runme.py b/Examples/test-suite/python/primitive_types_runme.py index c04dc9552..b2060a028 100644 --- a/Examples/test-suite/python/primitive_types_runme.py +++ b/Examples/test-suite/python/primitive_types_runme.py @@ -1,4 +1,3 @@ -import ctypes import sys from primitive_types import * @@ -443,6 +442,11 @@ if v != 4: # Check the bounds for converting various types # +# ctypes not available until 2.5 +if sys.version_info[0:2] <= (2, 4): + sys.exit(0) +import ctypes + # Get the minimum and maximum values that fit in signed char, short, int, long, and long long overchar = 2 ** 7 while ctypes.c_byte(overchar).value > 0: @@ -602,5 +606,6 @@ def checkType(name, maxfunc, maxval, minfunc, minval, echofunc): raise RuntimeError, "bad " + name + " typemap" # sys.maxsize is the largest value supported by Py_ssize_t, which should be the same as ptrdiff_t -checkType("ptrdiff_t", get_ptrdiff_max, sys.maxsize, get_ptrdiff_min, -(sys.maxsize + 1), ptrdiff_echo) -checkType("size_t", get_size_max, (2 * sys.maxsize) + 1, get_size_min, 0, size_echo) +if sys.version_info[0:2] >= (2, 6): + checkType("ptrdiff_t", get_ptrdiff_max, sys.maxsize, get_ptrdiff_min, -(sys.maxsize + 1), ptrdiff_echo) + checkType("size_t", get_size_max, (2 * sys.maxsize) + 1, get_size_min, 0, size_echo)