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
01284ab3
Commit
01284ab3
authored
Feb 09, 2021
by
da-woods
Committed by
GitHub
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
75da5a9e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
3 deletions
+19
-3
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+6
-2
tests/run/cimport.srctree
tests/run/cimport.srctree
+13
-1
No files found.
Cython/Compiler/ExprNodes.py
View file @
01284ab3
...
...
@@ -6214,7 +6214,7 @@ class PyMethodCallNode(SimpleCallNode):
# not an attribute itself, but might have been assigned from one (e.g. bound method)
for
assignment
in
self
.
function
.
cf_state
:
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
):
likely_method
=
'likely'
break
...
...
@@ -6938,7 +6938,11 @@ class AttributeNode(ExprNode):
# FIXME: this is way too redundant with analyse_types()
node
=
self
.
analyse_as_cimported_attribute_node
(
env
,
target
=
False
)
if
node
is
not
None
:
return
node
.
entry
.
type
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
node
=
self
.
analyse_as_type_attribute
(
env
)
if
node
is
not
None
:
return
node
.
entry
.
type
...
...
tests/run/cimport.srctree
View file @
01284ab3
...
...
@@ -41,6 +41,8 @@ ctypedef int my_int
######## a.pyx ########
from other cimport (
A,
foo,
...
...
@@ -48,7 +50,17 @@ from other cimport (
print(A, foo(10))
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
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