diff --git a/pyopencl/array.py b/pyopencl/array.py index 69a9f81b0ca5a3bde18b9c7f95fd247e66ba16c4..9d1b66b91ed59be814292237380a00f4b6261b32 100644 --- a/pyopencl/array.py +++ b/pyopencl/array.py @@ -425,13 +425,13 @@ class Array(object): # invariant here: allocator, queue set - # {{{ determine shape and strides + # {{{ determine shape, size, and strides dtype = np.dtype(dtype) try: - s = 1 + size = 1 for dim in shape: - s *= dim + size *= dim except TypeError: import sys if sys.version_info >= (3,): @@ -442,12 +442,11 @@ class Array(object): if not isinstance(shape, admissible_types): raise TypeError("shape must either be iterable or " "castable to an integer") - s = shape + size = shape shape = (shape,) - if isinstance(s, np.integer): - # bombs if s is a Python integer - s = np.asscalar(s) + if isinstance(size, np.integer): + size = size.item() if strides is None: strides = _make_strides(dtype.itemsize, shape, order) @@ -475,7 +474,7 @@ class Array(object): else: self.events = events - self.size = s + self.size = size alloc_nbytes = self.nbytes = self.dtype.itemsize * self.size self.allocator = allocator diff --git a/pyopencl/cache.py b/pyopencl/cache.py index 48b6270edcdc107b1aa006b4202feb3e6a29b36f..3e4bc65d13dc62267c5d12e3346842e4617327c8 100644 --- a/pyopencl/cache.py +++ b/pyopencl/cache.py @@ -480,7 +480,6 @@ def create_built_program_from_source_cached(ctx, src, options_bytes, devices=Non already_built = False except Exception as e: - raise from pyopencl import Error if (isinstance(e, Error) and e.code == _cl.status_code.BUILD_PROGRAM_FAILURE):