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
d4daf977
Commit
d4daf977
authored
Jun 15, 2013
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Perform typecheck for (typechecking) builtin casts.
parent
02be7fbc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+2
-1
tests/run/typetest_T417.pyx
tests/run/typetest_T417.pyx
+11
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
d4daf977
...
...
@@ -8034,6 +8034,7 @@ class TypecastNode(ExprNode):
# operand ExprNode
# base_type CBaseTypeNode
# declarator CDeclaratorNode
# typecheck boolean
#
# If used from a transform, one can if wanted specify the attribute
# "type" directly and leave base_type and declarator to None
...
...
@@ -8094,7 +8095,7 @@ class TypecastNode(ExprNode):
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
:
if
self
.
typecheck
and
self
.
type
.
is_
extension_type
:
if
self
.
typecheck
and
self
.
type
.
is_
pyobject
:
self
.
operand
=
PyTypeTestNode
(
self
.
operand
,
self
.
type
,
env
,
notnone
=
True
)
elif
isinstance
(
self
.
operand
,
SliceIndexNode
):
# This cast can influence the created type of string slices.
...
...
tests/run/typetest_T417.pyx
View file @
d4daf977
...
...
@@ -101,3 +101,14 @@ def test_getFooCast():
cdef
int
old_count
=
count
cdef
Foo
x
=
<
Foo
?
>
getFoo
()
return
count
-
old_count
def
test_builtin_typecheck_cast
(
maybe_list
):
"""
>>> test_builtin_typecheck_cast([])
[]
>>> test_builtin_typecheck_cast({})
Traceback (most recent call last):
...
TypeError: Expected list, got dict
"""
return
<
list
?
>
maybe_list
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