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
Kirill Smelkov
cython
Commits
750ce9c4
Commit
750ce9c4
authored
Jun 16, 2017
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass types as object, not name, in array conversion utility code.
This fixes #1737.
parent
b5ef664c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
7 deletions
+32
-7
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+4
-7
tests/run/carray_coercion.pyx
tests/run/carray_coercion.pyx
+28
-0
No files found.
Cython/Compiler/PyrexTypes.py
View file @
750ce9c4
...
@@ -2276,8 +2276,7 @@ class CArrayType(CPointerBaseType):
...
@@ -2276,8 +2276,7 @@ class CArrayType(CPointerBaseType):
if
not
self
.
base_type
.
create_to_py_utility_code
(
env
):
if
not
self
.
base_type
.
create_to_py_utility_code
(
env
):
return
False
return
False
base_type
=
self
.
base_type
.
declaration_code
(
""
,
pyrex
=
1
)
safe_typename
=
self
.
base_type
.
specialization_name
()
safe_typename
=
re
.
sub
(
'[^a-zA-Z0-9]'
,
'__'
,
base_type
)
to_py_function
=
"__Pyx_carray_to_py_%s"
%
safe_typename
to_py_function
=
"__Pyx_carray_to_py_%s"
%
safe_typename
to_tuple_function
=
"__Pyx_carray_to_tuple_%s"
%
safe_typename
to_tuple_function
=
"__Pyx_carray_to_tuple_%s"
%
safe_typename
...
@@ -2285,7 +2284,7 @@ class CArrayType(CPointerBaseType):
...
@@ -2285,7 +2284,7 @@ class CArrayType(CPointerBaseType):
context
=
{
context
=
{
'cname'
:
to_py_function
,
'cname'
:
to_py_function
,
'to_tuple_cname'
:
to_tuple_function
,
'to_tuple_cname'
:
to_tuple_function
,
'base_type'
:
base_type
,
'base_type'
:
self
.
base_type
,
}
}
env
.
use_utility_code
(
CythonUtilityCode
.
load
(
env
.
use_utility_code
(
CythonUtilityCode
.
load
(
"carray.to_py"
,
"CConvert.pyx"
,
"carray.to_py"
,
"CConvert.pyx"
,
...
@@ -2315,14 +2314,12 @@ class CArrayType(CPointerBaseType):
...
@@ -2315,14 +2314,12 @@ class CArrayType(CPointerBaseType):
if
not
self
.
base_type
.
create_from_py_utility_code
(
env
):
if
not
self
.
base_type
.
create_from_py_utility_code
(
env
):
return
False
return
False
base_type
=
self
.
base_type
.
declaration_code
(
""
,
pyrex
=
1
)
from_py_function
=
"__Pyx_carray_from_py_%s"
%
self
.
base_type
.
specialization_name
()
safe_typename
=
re
.
sub
(
'[^a-zA-Z0-9]'
,
'__'
,
base_type
)
from_py_function
=
"__Pyx_carray_from_py_%s"
%
safe_typename
from
.UtilityCode
import
CythonUtilityCode
from
.UtilityCode
import
CythonUtilityCode
context
=
{
context
=
{
'cname'
:
from_py_function
,
'cname'
:
from_py_function
,
'base_type'
:
base_type
,
'base_type'
:
self
.
base_type
,
}
}
env
.
use_utility_code
(
CythonUtilityCode
.
load
(
env
.
use_utility_code
(
CythonUtilityCode
.
load
(
"carray.from_py"
,
"CConvert.pyx"
,
"carray.from_py"
,
"CConvert.pyx"
,
...
...
tests/run/carray_coercion.pyx
View file @
750ce9c4
...
@@ -5,6 +5,10 @@ IS_PY3 = sys.version_info[0] >= 3
...
@@ -5,6 +5,10 @@ IS_PY3 = sys.version_info[0] >= 3
IS_32BIT_PY2
=
not
IS_PY3
and
sys
.
maxint
<
2
**
32
IS_32BIT_PY2
=
not
IS_PY3
and
sys
.
maxint
<
2
**
32
from
libc
cimport
stdint
from
libc.stdint
cimport
int64_t
as
my_int64_t
def
unlongify
(
v
):
def
unlongify
(
v
):
# on 32bit Py2.x platforms, 'unsigned int' coerces to a Python long => fix doctest output here.
# on 32bit Py2.x platforms, 'unsigned int' coerces to a Python long => fix doctest output here.
s
=
repr
(
v
)
s
=
repr
(
v
)
...
@@ -67,6 +71,30 @@ cpdef tuple tuple_from_typedef_int_array():
...
@@ -67,6 +71,30 @@ cpdef tuple tuple_from_typedef_int_array():
return
v
return
v
def
from_cimported_int_array
():
"""
>>> from_cimported_int_array()
[1, 2, 3]
"""
cdef
stdint
.
int32_t
[
3
]
v
v
[
0
]
=
1
v
[
1
]
=
2
v
[
2
]
=
3
return
v
def
from_cimported_as_int_array
():
"""
>>> from_cimported_as_int_array()
[1, 2, 3]
"""
cdef
my_int64_t
[
3
]
v
v
[
0
]
=
1
v
[
1
]
=
2
v
[
2
]
=
3
return
v
def
from_int_array_array
():
def
from_int_array_array
():
"""
"""
>>> from_int_array_array()
>>> from_int_array_array()
...
...
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