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
610c112a
Commit
610c112a
authored
Oct 25, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix carray assignments to char arrays and IndexNode
parent
48fa8563
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
14 deletions
+13
-14
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+11
-12
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+1
-1
Cython/Utility/CConvert.pyx
Cython/Utility/CConvert.pyx
+1
-1
No files found.
Cython/Compiler/ExprNodes.py
View file @
610c112a
...
@@ -3884,24 +3884,23 @@ class SliceIndexNode(ExprNode):
...
@@ -3884,24 +3884,23 @@ class SliceIndexNode(ExprNode):
check_negative_indices
(
self
.
start
,
self
.
stop
)
check_negative_indices
(
self
.
start
,
self
.
stop
)
base_type
=
self
.
base
.
type
base_type
=
self
.
base
.
type
if
base_type
.
is_string
or
base_type
.
is_cpp_string
:
if
base_type
.
is_array
and
not
getting
:
# cannot assign directly to C array => try to assign by making a copy
if
not
self
.
start
and
not
self
.
stop
:
self
.
type
=
base_type
else
:
self
.
type
=
PyrexTypes
.
CPtrType
(
base_type
.
base_type
)
elif
base_type
.
is_string
or
base_type
.
is_cpp_string
:
self
.
type
=
default_str_type
(
env
)
self
.
type
=
default_str_type
(
env
)
elif
base_type
.
is_pyunicode_ptr
:
elif
base_type
.
is_pyunicode_ptr
:
self
.
type
=
unicode_type
self
.
type
=
unicode_type
elif
base_type
.
is_ptr
:
elif
base_type
.
is_ptr
:
self
.
type
=
base_type
self
.
type
=
base_type
elif
base_type
.
is_array
:
elif
base_type
.
is_array
:
if
getting
:
# we need a ptr type here instead of an array type, as
# we need a ptr type here instead of an array type, as
# array types can result in invalid type casts in the C
# array types can result in invalid type casts in the C
# code
# code
self
.
type
=
PyrexTypes
.
CPtrType
(
base_type
.
base_type
)
self
.
type
=
PyrexTypes
.
CPtrType
(
base_type
.
base_type
)
else
:
# try to assign 'by value' (i.e. make a copy)
if
not
self
.
start
and
not
self
.
stop
:
self
.
type
=
base_type
else
:
self
.
type
=
PyrexTypes
.
CPtrType
(
base_type
.
base_type
)
else
:
else
:
self
.
base
=
self
.
base
.
coerce_to_pyobject
(
env
)
self
.
base
=
self
.
base
.
coerce_to_pyobject
(
env
)
self
.
type
=
py_object_type
self
.
type
=
py_object_type
...
...
Cython/Compiler/Nodes.py
View file @
610c112a
...
@@ -4758,7 +4758,7 @@ class SingleAssignmentNode(AssignmentNode):
...
@@ -4758,7 +4758,7 @@ class SingleAssignmentNode(AssignmentNode):
self
.
lhs
.
is_memslice_scalar_assignment
=
True
self
.
lhs
.
is_memslice_scalar_assignment
=
True
dtype
=
self
.
lhs
.
type
.
dtype
dtype
=
self
.
lhs
.
type
.
dtype
elif
self
.
lhs
.
type
.
is_array
:
elif
self
.
lhs
.
type
.
is_array
:
if
not
isinstance
(
self
.
lhs
,
(
ExprNodes
.
IndexNode
,
ExprNodes
.
SliceIndexNode
)
):
if
not
isinstance
(
self
.
lhs
,
ExprNodes
.
SliceIndexNode
):
# cannot assign to C array, only to its full slice
# cannot assign to C array, only to its full slice
self
.
lhs
=
ExprNodes
.
SliceIndexNode
(
self
.
lhs
=
ExprNodes
.
SliceIndexNode
(
self
.
lhs
.
pos
,
base
=
self
.
lhs
,
start
=
None
,
stop
=
None
)
self
.
lhs
.
pos
,
base
=
self
.
lhs
,
start
=
None
,
stop
=
None
)
...
...
Cython/Utility/CConvert.pyx
View file @
610c112a
...
@@ -18,7 +18,7 @@ cdef {{struct_name}} {{funcname}}(obj) except *:
...
@@ -18,7 +18,7 @@ cdef {{struct_name}} {{funcname}}(obj) except *:
value
=
obj
[
'{{member.name}}'
]
value
=
obj
[
'{{member.name}}'
]
except
KeyError
:
except
KeyError
:
raise
ValueError
(
"No value specified for struct attribute '{{member.name}}'"
)
raise
ValueError
(
"No value specified for struct attribute '{{member.name}}'"
)
result
.{{
member
.
cname
}}
{{
'[:]'
if
member
.
type
.
is_array
else
''
}}
=
value
result
.{{
member
.
cname
}}
=
value
{{
endfor
}}
{{
endfor
}}
return
result
return
result
...
...
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