Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
de3cdbbe
Commit
de3cdbbe
authored
May 06, 2012
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't allow more dimensions than buffer_max_dims
parent
1ad72710
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
3 deletions
+29
-3
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+5
-0
Cython/Compiler/MemoryView.py
Cython/Compiler/MemoryView.py
+8
-0
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+6
-3
tests/errors/memview_declarations.pyx
tests/errors/memview_declarations.pyx
+10
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
de3cdbbe
...
...
@@ -2644,6 +2644,11 @@ class IndexNode(ExprNode):
self
.
index
=
None
self
.
is_temp
=
True
self
.
use_managed_ref
=
True
if
not
MemoryView
.
validate_axes
(
self
.
pos
,
axes
):
self
.
type
=
error_type
return
self
.
type
=
PyrexTypes
.
MemoryViewSliceType
(
self
.
base
.
type
.
dtype
,
axes
)
...
...
Cython/Compiler/MemoryView.py
View file @
de3cdbbe
...
...
@@ -723,6 +723,14 @@ def get_axes_specs(env, axes):
return
axes_specs
def
validate_axes
(
pos
,
axes
):
if
len
(
axes
)
>=
Options
.
buffer_max_dims
:
error
(
pos
,
"More dimensions than the maximum number"
" of buffer dimensions were used."
)
return
False
return
True
def
all
(
it
):
for
item
in
it
:
if
not
item
:
...
...
Cython/Compiler/Nodes.py
View file @
de3cdbbe
...
...
@@ -883,10 +883,13 @@ class MemoryViewSliceTypeNode(CBaseTypeNode):
self
.
type
=
PyrexTypes
.
ErrorType
()
return
self
.
type
MemoryView
.
validate_memslice_dtype
(
self
.
pos
,
base_type
)
self
.
type
=
PyrexTypes
.
MemoryViewSliceType
(
base_type
,
axes_specs
)
if
not
MemoryView
.
validate_axes
(
self
.
pos
,
axes_specs
):
self
.
type
=
error_type
else
:
MemoryView
.
validate_memslice_dtype
(
self
.
pos
,
base_type
)
self
.
type
=
PyrexTypes
.
MemoryViewSliceType
(
base_type
,
axes_specs
)
self
.
use_memview_utilities
(
env
)
self
.
use_memview_utilities
(
env
)
return
self
.
type
def
use_memview_utilities
(
self
,
env
):
...
...
tests/errors/memview_declarations.pyx
View file @
de3cdbbe
...
...
@@ -54,8 +54,15 @@ cdef struct Invalid:
cdef
Valid
[:]
validslice
cdef
Invalid
[:]
invalidslice
cdef
int
[:,
:,
:,
:]
four_D
four_D
[
None
,
None
,
None
,
None
]
four_D
[
None
,
None
,
None
,
None
,
None
]
cdef
int
[:,
:,
:,
:,
:,
:,
:,
:]
eight_D
=
object
()
# These are VALID
cdef
int
[::
view
.
indirect_contiguous
,
::
view
.
contiguous
]
a9
four_D
[
None
,
None
,
None
]
_ERRORS
=
u'''
11:25: Cannot specify an array that is both C and Fortran contiguous.
...
...
@@ -79,4 +86,7 @@ _ERRORS = u'''
46:35: Can only create cython.array from pointer or array
47:24: Cannot assign type 'double' to 'Py_ssize_t'
55:13: Invalid base type for memoryview slice: Invalid
58:6: More dimensions than the maximum number of buffer dimensions were used.
59:6: More dimensions than the maximum number of buffer dimensions were used.
61:9: More dimensions than the maximum number of buffer dimensions were used.
'''
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment