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
7d69ae07
Commit
7d69ae07
authored
Feb 09, 2021
by
da-woods
Committed by
Stefan Behnel
Feb 09, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't crash when probing type of cimported module (GH-4001)
Closes
https://github.com/cython/cython/issues/4000
parent
921cd966
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
4 deletions
+20
-4
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+6
-2
tests/run/cimport.srctree
tests/run/cimport.srctree
+14
-2
No files found.
Cython/Compiler/ExprNodes.py
View file @
7d69ae07
...
@@ -6049,7 +6049,7 @@ class PyMethodCallNode(SimpleCallNode):
...
@@ -6049,7 +6049,7 @@ class PyMethodCallNode(SimpleCallNode):
# not an attribute itself, but might have been assigned from one (e.g. bound method)
# not an attribute itself, but might have been assigned from one (e.g. bound method)
for
assignment
in
self
.
function
.
cf_state
:
for
assignment
in
self
.
function
.
cf_state
:
value
=
assignment
.
rhs
value
=
assignment
.
rhs
if
value
and
value
.
is_attribute
and
value
.
obj
.
type
.
is_pyobject
:
if
value
and
value
.
is_attribute
and
value
.
obj
.
type
and
value
.
obj
.
type
.
is_pyobject
:
if
attribute_is_likely_method
(
value
):
if
attribute_is_likely_method
(
value
):
likely_method
=
'likely'
likely_method
=
'likely'
break
break
...
@@ -6851,6 +6851,10 @@ class AttributeNode(ExprNode):
...
@@ -6851,6 +6851,10 @@ class AttributeNode(ExprNode):
# FIXME: this is way too redundant with analyse_types()
# FIXME: this is way too redundant with analyse_types()
node
=
self
.
analyse_as_cimported_attribute_node
(
env
,
target
=
False
)
node
=
self
.
analyse_as_cimported_attribute_node
(
env
,
target
=
False
)
if
node
is
not
None
:
if
node
is
not
None
:
if
node
.
entry
.
type
and
node
.
entry
.
type
.
is_cfunction
:
# special-case - function converted to pointer
return
PyrexTypes
.
CPtrType
(
node
.
entry
.
type
)
else
:
return
node
.
entry
.
type
return
node
.
entry
.
type
node
=
self
.
analyse_as_type_attribute
(
env
)
node
=
self
.
analyse_as_type_attribute
(
env
)
if
node
is
not
None
:
if
node
is
not
None
:
...
...
tests/run/cimport.srctree
View file @
7d69ae07
...
@@ -41,6 +41,8 @@ ctypedef int my_int
...
@@ -41,6 +41,8 @@ ctypedef int my_int
######## a.pyx ########
######## a.pyx ########
from other cimport (
from other cimport (
A,
A,
foo,
foo,
...
@@ -48,7 +50,17 @@ from other cimport (
...
@@ -48,7 +50,17 @@ from other cimport (
print A, foo(10)
print A, foo(10)
cimport other
cimport other
print other.A, other.foo(10)
cdef call_fooptr(int (*fptr)(int)):
return fptr(10)
def call_other_foo():
x = other.foo # GH4000 - failed because other was untyped
return call_fooptr(x) # check that x is correctly resolved as a function pointer
print(other.A, other.foo(10), call_other_foo())
from pkg cimport sub
from pkg cimport sub
cdef sub.my_int a = 100
cdef sub.my_int a = 100
...
...
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