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
4d115ea6
Commit
4d115ea6
authored
Jul 30, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create intermediate parent module chain when cimporting from a sub-package
parent
22f67f24
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
3 deletions
+30
-3
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+15
-3
tests/run/relative_cimport.srctree
tests/run/relative_cimport.srctree
+15
-0
No files found.
Cython/Compiler/Symtab.py
View file @
4d115ea6
...
@@ -1161,16 +1161,28 @@ class ModuleScope(Scope):
...
@@ -1161,16 +1161,28 @@ class ModuleScope(Scope):
def
find_submodule
(
self
,
name
):
def
find_submodule
(
self
,
name
):
# Find and return scope for a submodule of this module,
# Find and return scope for a submodule of this module,
# creating a new empty one if necessary. Doesn't parse .pxd.
# creating a new empty one if necessary. Doesn't parse .pxd.
if
'.'
in
name
:
name
,
submodule
=
name
.
split
(
'.'
,
1
)
else
:
submodule
=
None
scope
=
self
.
lookup_submodule
(
name
)
scope
=
self
.
lookup_submodule
(
name
)
if
not
scope
:
if
not
scope
:
scope
=
ModuleScope
(
name
,
scope
=
ModuleScope
(
name
,
parent_module
=
self
,
context
=
self
.
context
)
parent_module
=
self
,
context
=
self
.
context
)
self
.
module_entries
[
name
]
=
scope
self
.
module_entries
[
name
]
=
scope
if
submodule
:
scope
=
scope
.
find_submodule
(
submodule
)
return
scope
return
scope
def
lookup_submodule
(
self
,
name
):
def
lookup_submodule
(
self
,
name
):
# Return scope for submodule of this module, or None.
# Return scope for submodule of this module, or None.
return
self
.
module_entries
.
get
(
name
,
None
)
if
'.'
in
name
:
name
,
submodule
=
name
.
split
(
'.'
,
1
)
else
:
submodule
=
None
module
=
self
.
module_entries
.
get
(
name
,
None
)
if
submodule
and
module
is
not
None
:
module
=
module
.
lookup_submodule
(
submodule
)
return
module
def
add_include_file
(
self
,
filename
):
def
add_include_file
(
self
,
filename
):
if
filename
not
in
self
.
python_include_files
\
if
filename
not
in
self
.
python_include_files
\
...
...
tests/run/relative_cimport.srctree
View file @
4d115ea6
...
@@ -22,6 +22,11 @@ setup(
...
@@ -22,6 +22,11 @@ setup(
######## pkg/a.pyx ########
######## pkg/a.pyx ########
from .sub.reimport cimport myint
cdef myint i = 5
assert i == 5
cdef class test_pxd:
cdef class test_pxd:
pass
pass
...
@@ -59,3 +64,13 @@ def test():
...
@@ -59,3 +64,13 @@ def test():
obj.x = 1
obj.x = 1
obj.y = 2
obj.y = 2
return (obj.x, obj.y)
return (obj.x, obj.y)
######## pkg/sub/tdef.pxd ########
ctypedef int myint
######## pkg/sub/reimport.pxd ########
from .tdef cimport myint
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