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
6e2e7a56
Commit
6e2e7a56
authored
Jan 13, 2011
by
Vitja Makarov
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote branch 'upstream/master'
parents
2eb1156a
d8207c2b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
1 deletion
+33
-1
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+11
-1
tests/run/type_inference.pyx
tests/run/type_inference.pyx
+22
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
6e2e7a56
...
...
@@ -1302,6 +1302,9 @@ class NameNode(AtomicExprNode):
# Unfortunately the type attribute of type objects
# is used for the pointer to the type they represent.
return
type_type
elif
self
.
entry
.
type
.
is_cfunction
:
# special case: referring to a C function must return its pointer
return
PyrexTypes
.
CPtrType
(
self
.
entry
.
type
)
else
:
return
self
.
entry
.
type
...
...
@@ -3360,7 +3363,14 @@ class AttributeNode(ExprNode):
elif
self
.
analyse_as_unbound_cmethod
(
env
):
return
self
.
entry
.
type
else
:
self
.
analyse_attribute
(
env
,
obj_type
=
self
.
obj
.
infer_type
(
env
))
obj_type
=
self
.
obj
.
infer_type
(
env
)
self
.
analyse_attribute
(
env
,
obj_type
=
obj_type
)
if
obj_type
.
is_builtin_type
and
self
.
type
.
is_cfunction
:
# special case: C-API replacements for C methods of
# builtin types cannot be inferred as C functions as
# that would prevent their use as bound methods
self
.
type
=
py_object_type
return
py_object_type
return
self
.
type
def
analyse_target_declaration
(
self
,
env
):
...
...
tests/run/type_inference.pyx
View file @
6e2e7a56
...
...
@@ -199,6 +199,28 @@ def builtin_type_operations():
T2
=
()
*
2
assert
typeof
(
T2
)
==
"tuple object"
,
typeof
(
T2
)
def
builtin_type_methods
():
"""
>>> builtin_type_methods()
"""
l
=
[]
assert
typeof
(
l
)
==
'list object'
,
typeof
(
l
)
append
=
l
.
append
assert
typeof
(
append
)
==
'Python object'
,
typeof
(
append
)
append
(
1
)
assert
l
==
[
1
],
str
(
l
)
cdef
int
func
(
int
x
):
return
x
+
1
def
c_functions
():
"""
>>> c_functions()
"""
f
=
func
assert
typeof
(
f
)
==
'int (*)(int)'
,
typeof
(
f
)
assert
2
==
f
(
1
)
def
cascade
():
"""
>>> cascade()
...
...
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