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
e224cced
Commit
e224cced
authored
Jul 08, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow coercion of temp values to C++ classes
parent
dd71d21c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
2 deletions
+13
-2
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+3
-2
tests/run/cpp_stl_conversion.pyx
tests/run/cpp_stl_conversion.pyx
+10
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
e224cced
...
...
@@ -7297,7 +7297,8 @@ class TypecastNode(ExprNode):
self
.
operand
.
analyse_types
(
env
)
to_py
=
self
.
type
.
is_pyobject
from_py
=
self
.
operand
.
type
.
is_pyobject
if
from_py
and
not
to_py
and
self
.
operand
.
is_ephemeral
()
and
not
self
.
type
.
is_numeric
:
if
from_py
and
not
to_py
and
self
.
operand
.
is_ephemeral
():
if
not
self
.
type
.
is_numeric
and
not
self
.
type
.
is_cpp_class
:
error
(
self
.
pos
,
"Casting temporary Python object to non-numeric non-Python type"
)
if
to_py
and
not
from_py
:
if
self
.
type
is
bytes_type
and
self
.
operand
.
type
.
is_int
:
...
...
tests/run/cpp_stl_conversion.pyx
View file @
e224cced
...
...
@@ -39,6 +39,16 @@ def test_encode_to_string(o):
cdef
string
s
=
o
.
encode
(
'ascii'
)
return
s
def
test_encode_to_string_cast
(
o
):
"""
>>> normalize(test_encode_to_string_cast('abc'))
'abc'
>>> normalize(test_encode_to_string_cast('abc
\
\
x00def'))
'abc
\
\
x00def'
"""
s
=
<
string
>
o
.
encode
(
'ascii'
)
return
s
def
test_bytes_encode_to_string
(
bytes
o
):
"""
>>> normalize(test_bytes_encode_to_string('abc'))
...
...
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