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
9a8dcfde
Commit
9a8dcfde
authored
Apr 06, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix Py2.x style implicit relative cimports (try relative first, then absolute)
parent
14746524
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
+8
-3
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+6
-3
tests/run/relative_cimport.srctree
tests/run/relative_cimport.srctree
+2
-0
No files found.
Cython/Compiler/Symtab.py
View file @
9a8dcfde
...
...
@@ -1128,15 +1128,18 @@ class ModuleScope(Scope):
# Finds and parses the module's .pxd file if the module
# has not been referenced before.
relative_to
=
None
if
relative_level
is
not
None
and
relative_level
>
0
:
absolute_fallback
=
False
if
relative_level
is
not
None
and
relative_level
>
0
:
# explicit relative cimport
# error of going beyond top-level is handled in cimport node
relative_to
=
self
while
relative_level
>
0
and
relative_to
:
relative_to
=
relative_to
.
parent_module
relative_level
-=
1
else
:
absolute_fallback
=
relative_level
!=
0
# might be None!
elif
relative_level
!=
0
:
# -1 or None: try relative cimport first, then absolute
relative_to
=
self
.
parent_module
absolute_fallback
=
True
module_scope
=
self
.
global_scope
()
return
module_scope
.
context
.
find_module
(
...
...
tests/run/relative_cimport.srctree
View file @
9a8dcfde
...
...
@@ -37,8 +37,10 @@ cdef class test_pxd:
from . cimport a
from .a cimport test_pxd
cimport a as implicitly_relative_a
assert a.test_pxd is test_pxd
assert implicitly_relative_a.test_pxd is test_pxd
def test():
cdef test_pxd obj = test_pxd()
...
...
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