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 ...@@ -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, Builtin=object, Symtab=object, Utils=object, find_coercion_error=object,
debug_disposal_code=object, debug_temp_alloc=object, debug_coercion=object) debug_disposal_code=object, debug_temp_alloc=object, debug_coercion=object)
import sys
import operator import operator
from Errors import error, warning, warn_once, InternalError, CompileError from Errors import error, warning, warn_once, InternalError, CompileError
...@@ -3078,6 +3079,12 @@ class IndexNode(ExprNode): ...@@ -3078,6 +3079,12 @@ class IndexNode(ExprNode):
buffer_entry = self.buffer_entry() buffer_entry = self.buffer_entry()
have_gil = not self.in_nogil_context have_gil = not self.in_nogil_context
if sys.version_info < (3,):
def next_(it):
return it.next()
else:
next_ = next
have_slices = False have_slices = False
it = iter(self.indices) it = iter(self.indices)
for index in self.original_indices: for index in self.original_indices:
...@@ -3085,13 +3092,13 @@ class IndexNode(ExprNode): ...@@ -3085,13 +3092,13 @@ class IndexNode(ExprNode):
have_slices = have_slices or is_slice have_slices = have_slices or is_slice
if is_slice: if is_slice:
if not index.start.is_none: if not index.start.is_none:
index.start = it.next() index.start = next_(it)
if not index.stop.is_none: if not index.stop.is_none:
index.stop = it.next() index.stop = next_(it)
if not index.step.is_none: if not index.step.is_none:
index.step = it.next() index.step = next_(it)
else: else:
it.next() next_(it)
assert not list(it) assert not list(it)
......
...@@ -510,8 +510,8 @@ class ContigSliceIter(SliceIter): ...@@ -510,8 +510,8 @@ class ContigSliceIter(SliceIter):
for i in range(self.ndim)) for i in range(self.ndim))
code.putln("Py_ssize_t __pyx_temp_extent = %s;" % total_size) code.putln("Py_ssize_t __pyx_temp_extent = %s;" % total_size)
code.putln("Py_ssize_t __pyx_temp_idx;") code.putln("Py_ssize_t __pyx_temp_idx;")
code.putln("%s *__pyx_temp_pointer = %s.data;" % (type_decl, code.putln("%s *__pyx_temp_pointer = (%s *) %s.data;" % (
self.slice_temp)) type_decl, type_decl, self.slice_temp))
code.putln("for (__pyx_temp_idx = 0; " code.putln("for (__pyx_temp_idx = 0; "
"__pyx_temp_idx < __pyx_temp_extent; " "__pyx_temp_idx < __pyx_temp_extent; "
"__pyx_temp_idx++) {") "__pyx_temp_idx++) {")
......
...@@ -407,11 +407,14 @@ cdef class memoryview(object): ...@@ -407,11 +407,14 @@ cdef class memoryview(object):
else: else:
item = <void *> array item = <void *> array
try: if self.dtype_is_object:
self.assign_item_from_object(<char *> item, value) (<PyObject **> item)[0] = <PyObject *> value
except: else:
free(tmp) try:
raise self.assign_item_from_object(<char *> item, value)
except:
free(tmp)
raise
# It would be easy to support indirect dimensions, but it's easier # It would be easy to support indirect dimensions, but it's easier
# to disallow :) # 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