Commit beb90546 authored by Mark Florisson's avatar Mark Florisson

Intialize object item pointer properly & C++ compat

parent 59c8151f
......@@ -12,6 +12,7 @@ cython.declare(error=object, warning=object, warn_once=object, InternalError=obj
Builtin=object, Symtab=object, Utils=object, find_coercion_error=object,
debug_disposal_code=object, debug_temp_alloc=object, debug_coercion=object)
import sys
import operator
from Errors import error, warning, warn_once, InternalError, CompileError
......@@ -3078,6 +3079,12 @@ class IndexNode(ExprNode):
buffer_entry = self.buffer_entry()
have_gil = not self.in_nogil_context
if sys.version_info < (3,):
def next_(it):
return it.next()
else:
next_ = next
have_slices = False
it = iter(self.indices)
for index in self.original_indices:
......@@ -3085,13 +3092,13 @@ class IndexNode(ExprNode):
have_slices = have_slices or is_slice
if is_slice:
if not index.start.is_none:
index.start = it.next()
index.start = next_(it)
if not index.stop.is_none:
index.stop = it.next()
index.stop = next_(it)
if not index.step.is_none:
index.step = it.next()
index.step = next_(it)
else:
it.next()
next_(it)
assert not list(it)
......
......@@ -510,8 +510,8 @@ class ContigSliceIter(SliceIter):
for i in range(self.ndim))
code.putln("Py_ssize_t __pyx_temp_extent = %s;" % total_size)
code.putln("Py_ssize_t __pyx_temp_idx;")
code.putln("%s *__pyx_temp_pointer = %s.data;" % (type_decl,
self.slice_temp))
code.putln("%s *__pyx_temp_pointer = (%s *) %s.data;" % (
type_decl, type_decl, self.slice_temp))
code.putln("for (__pyx_temp_idx = 0; "
"__pyx_temp_idx < __pyx_temp_extent; "
"__pyx_temp_idx++) {")
......
......@@ -407,11 +407,14 @@ cdef class memoryview(object):
else:
item = <void *> array
try:
self.assign_item_from_object(<char *> item, value)
except:
free(tmp)
raise
if self.dtype_is_object:
(<PyObject **> item)[0] = <PyObject *> value
else:
try:
self.assign_item_from_object(<char *> item, value)
except:
free(tmp)
raise
# It would be easy to support indirect dimensions, but it's easier
# to disallow :)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment