diff --git a/buildtests/relimp3a/__init__.py b/buildtests/relimp3a/__init__.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/buildtests/relimp3a/__init__.py @@ -0,0 +1 @@ + diff --git a/buildtests/relimp3a/aa/__init__.py b/buildtests/relimp3a/aa/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/buildtests/relimp3a/aa/a1.py b/buildtests/relimp3a/aa/a1.py new file mode 100644 index 0000000..cac7d99 --- /dev/null +++ b/buildtests/relimp3a/aa/a1.py @@ -0,0 +1,6 @@ +from .relimp3b import b1 +from .relimp3c import c1 + +def getString(): + return b1.string + c1.string + diff --git a/buildtests/relimp3a/aa/relimp3c.py b/buildtests/relimp3a/aa/relimp3c.py new file mode 100644 index 0000000..710c942 --- /dev/null +++ b/buildtests/relimp3a/aa/relimp3c.py @@ -0,0 +1,2 @@ +class c1: + string = "... and this" diff --git a/buildtests/relimp3a/relimp3b.py b/buildtests/relimp3a/relimp3b.py new file mode 100644 index 0000000..68263d9 --- /dev/null +++ b/buildtests/relimp3a/relimp3b.py @@ -0,0 +1 @@ +raise ValueError diff --git a/buildtests/relimp3a/relimp3c.py b/buildtests/relimp3a/relimp3c.py new file mode 100644 index 0000000..68263d9 --- /dev/null +++ b/buildtests/relimp3a/relimp3c.py @@ -0,0 +1 @@ +raise ValueError diff --git a/buildtests/relimp3b/__init__.py b/buildtests/relimp3b/__init__.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/buildtests/relimp3b/__init__.py @@ -0,0 +1 @@ + diff --git a/buildtests/relimp3b/b1.py b/buildtests/relimp3b/b1.py new file mode 100644 index 0000000..78ff89b --- /dev/null +++ b/buildtests/relimp3b/b1.py @@ -0,0 +1 @@ +string = "I hope you see this!" diff --git a/buildtests/relimp3c/__init__.py b/buildtests/relimp3c/__init__.py new file mode 100644 index 0000000..a9615e1 --- /dev/null +++ b/buildtests/relimp3c/__init__.py @@ -0,0 +1 @@ +raise RuntimeError diff --git a/buildtests/test-relative-import3.py b/buildtests/test-relative-import3.py new file mode 100644 index 0000000..a81039b --- /dev/null +++ b/buildtests/test-relative-import3.py @@ -0,0 +1,4 @@ +from relimp3a.aa import a1 + +if __name__ == '__main__': + print a1.getString() diff --git a/buildtests/test-relative-import3.spec b/buildtests/test-relative-import3.spec new file mode 100644 index 0000000..087a268 --- /dev/null +++ b/buildtests/test-relative-import3.spec @@ -0,0 +1,17 @@ +# -*- mode: python -*- + +__testname__ = 'test-relative-import3' + +a = Analysis([os.path.join(HOMEPATH,'support/_mountzlib.py'), + __testname__ + '.py'], + ) +pyz = PYZ(a.pure) +exe = EXE(pyz, + a.scripts, + a.binaries, + a.zipfiles, + name = os.path.join('dist', __testname__, __testname__ +'.exe'), + debug=False, + strip=False, + upx=False, + console=1 ) diff --git a/iu.py b/iu.py index fa92434..27258f6 100644 --- a/iu.py +++ b/iu.py @@ -406,7 +406,7 @@ class ImportManager: if level > 1: importernm = _string_split(importernm, '.')[:-level+1] importernm = _string_join('.', importernm) - contexts = [] + contexts = [None] if importernm: if ispkg: # If you use the "from __init__ import" syntax, the package diff --git a/mf.py b/mf.py index db16d3f..d7872db 100644 --- a/mf.py +++ b/mf.py @@ -494,7 +494,7 @@ class ImportTracker: level -= 1 if level > 0: importernm = string.join(string.split(importernm, '.')[:-level], ".") - contexts = [importernm] + contexts = [importernm, None] importernm = None _all = None