[pypy-svn] pypy default: (antocuni, fijal) a test and a fix

fijal commits-noreply at bitbucket.org
Thu Jan 20 18:59:11 CET 2011


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: 
Changeset: r41064:f938be98d294
Date: 2011-01-20 19:58 +0200
http://bitbucket.org/pypy/pypy/changeset/f938be98d294/

Log:	(antocuni, fijal) a test and a fix

diff --git a/pypy/module/zipimport/interp_zipimport.py b/pypy/module/zipimport/interp_zipimport.py
--- a/pypy/module/zipimport/interp_zipimport.py
+++ b/pypy/module/zipimport/interp_zipimport.py
@@ -229,7 +229,7 @@
         startpos = fullname.rfind('.') + 1 # 0 when not found
         assert startpos >= 0
         subname = fullname[startpos:]
-        return self.prefix + subname
+        return self.prefix + subname.replace('.', '/')
 
     def load_module(self, space, fullname):
         w = space.wrap
@@ -247,7 +247,7 @@
                 pass
             else:
                 if is_package:
-                    pkgpath = (self.name + os.path.sep +
+                    pkgpath = (self.filename + os.path.sep +
                                self.corr_zname(filename))
                 else:
                     pkgpath = None

diff --git a/pypy/module/zipimport/test/test_zipimport.py b/pypy/module/zipimport/test/test_zipimport.py
--- a/pypy/module/zipimport/test/test_zipimport.py
+++ b/pypy/module/zipimport/test/test_zipimport.py
@@ -306,6 +306,22 @@
         assert z.is_package("package")
         assert z.get_filename("package") == mod.__file__
 
+    def test_subdirectory_twice(self):
+        import os, zipimport
+ 
+        self.writefile(
+            os.sep.join(("package", "__init__.py")), "")
+        self.writefile(
+            os.sep.join(("package", "subpackage",
+                         "__init__.py")), "")
+        self.writefile(
+            os.sep.join(("package", "subpackage",
+                         "foo.py")), "")
+        import sys
+        print sys.path
+        mod = __import__('package.subpackage.foo', None, None, [])
+        assert mod
+
     def test_zip_directory_cache(self):
         """ Check full dictionary interface
         """


More information about the Pypy-commit mailing list