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
1eb59492
Commit
1eb59492
authored
May 14, 2009
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disallow <double*>obj (#313). Also removes warning for <void*>obj.
parent
d125223d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
0 deletions
+29
-0
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+2
-0
tests/errors/pyobjcastdisallow_T313.pyx
tests/errors/pyobjcastdisallow_T313.pyx
+9
-0
tests/run/pyobjcast_T313.pyx
tests/run/pyobjcast_T313.pyx
+18
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
1eb59492
...
...
@@ -3937,6 +3937,8 @@ class TypecastNode(NewTempExprNode):
elif
from_py
and
not
to_py
:
if
self
.
type
.
from_py_function
:
self
.
operand
=
self
.
operand
.
coerce_to
(
self
.
type
,
env
)
elif
self
.
type
.
is_ptr
and
not
self
.
type
.
base_type
.
is_void
:
error
(
self
.
pos
,
"Python objects can only be cast to void*"
)
else
:
warning
(
self
.
pos
,
"No conversion from %s to %s, python object pointer used."
%
(
self
.
type
,
self
.
operand
.
type
))
elif
from_py
and
to_py
:
...
...
tests/errors/pyobjcastdisallow_T313.pyx
0 → 100644
View file @
1eb59492
a
=
3
cdef
void
*
allowed
=
<
void
*>
a
cdef
double
*
disallowed
=
<
double
*>
a
_ERRORS
=
u"""
5:26: Python objects can only be cast to void*
"""
tests/run/pyobjcast_T313.pyx
0 → 100644
View file @
1eb59492
# Ensure casting still works to void*
"""
>>> f()
('teststring', 'teststring')
"""
cdef
extern
from
*
:
ctypedef
void
PyObject
def
f
():
cdef
void
*
p1
cdef
PyObject
*
p2
a
=
"teststring"
p1
=
<
void
*>
a
p2
=
<
PyObject
*>
a
return
(
<
object
>
p1
,
<
object
>
p2
)
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