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
395b89c1
Commit
395b89c1
authored
Jun 17, 2021
by
da-woods
Committed by
GitHub
Jun 17, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix conversion from DictNode to std::map (GH-4231)
Reported in
https://github.com/cython/cython/pull/4228
parent
28c98012
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
6 deletions
+30
-6
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+1
-2
tests/errors/reversed_literal_pyobjs.pyx
tests/errors/reversed_literal_pyobjs.pyx
+1
-4
tests/run/cpp_stl_conversion.pyx
tests/run/cpp_stl_conversion.pyx
+28
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
395b89c1
...
...
@@ -8871,8 +8871,7 @@ class DictNode(ExprNode):
value
=
value
.
arg
item
.
value
=
value
.
coerce_to
(
member
.
type
,
env
)
else
:
self
.
type
=
error_type
error
(
self
.
pos
,
"Cannot interpret dict as type '%s'"
%
dst_type
)
return
super
(
DictNode
,
self
).
coerce_to
(
dst_type
,
env
)
return
self
def
release_errors
(
self
):
...
...
tests/errors/reversed_literal_pyobjs.pyx
View file @
395b89c1
...
...
@@ -10,6 +10,7 @@ for i in reversed(range(j, [], 2)):
pass
for
i
in
reversed
(
range
(
j
,
[],
-
2
)):
pass
# code below is no longer a compile-time error (although won't run without an exception)
for
i
in
reversed
(
range
({},
j
,
2
)):
pass
for
i
in
reversed
(
range
({},
j
,
-
2
)):
...
...
@@ -24,8 +25,4 @@ _ERRORS = """
7:24: Cannot coerce list to type 'long'
9:27: Cannot coerce list to type 'long'
11:27: Cannot coerce list to type 'long'
13:24: Cannot interpret dict as type 'long'
15:24: Cannot interpret dict as type 'long'
17:27: Cannot interpret dict as type 'long'
19:27: Cannot interpret dict as type 'long'
"""
tests/run/cpp_stl_conversion.pyx
View file @
395b89c1
...
...
@@ -97,6 +97,23 @@ def test_int_vector(o):
cdef
vector
[
int
]
v
=
o
return
v
cdef
vector
[
int
]
takes_vector
(
vector
[
int
]
x
):
return
x
def
test_list_literal_to_vector
():
"""
>>> test_list_literal_to_vector()
[1, 2, 3]
"""
return
takes_vector
([
1
,
2
,
3
])
def
test_tuple_literal_to_vector
():
"""
>>> test_tuple_literal_to_vector()
[1, 2, 3]
"""
return
takes_vector
((
1
,
2
,
3
))
def
test_string_vector
(
s
):
"""
>>> list(map(normalize, test_string_vector('ab cd ef gh'.encode('ascii'))))
...
...
@@ -241,3 +258,14 @@ def test_enum_map(o):
"""
cdef
map
[
Color
,
Color
]
m
=
o
return
m
cdef
map
[
unsigned
int
,
unsigned
int
]
takes_map
(
map
[
unsigned
int
,
unsigned
int
]
m
):
return
m
def
test_dict_literal_to_map
():
"""
>>> test_dict_literal_to_map()
{1: 1}
"""
return
takes_map
({
1
:
1
})
# https://github.com/cython/cython/pull/4228
# DictNode could not be converted directly
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