[pypy-svn] r64411 - pypy/trunk/pypy/module/zipimport

tismer at codespeak.net tismer at codespeak.net
Sun Apr 19 20:28:50 CEST 2009


Author: tismer
Date: Sun Apr 19 20:28:49 2009
New Revision: 64411

Modified:
   pypy/trunk/pypy/module/zipimport/interp_zipimport.py
Log:
fix the __file__ attribute of zip-imported modules for windows.

Modified: pypy/trunk/pypy/module/zipimport/interp_zipimport.py
==============================================================================
--- pypy/trunk/pypy/module/zipimport/interp_zipimport.py	(original)
+++ pypy/trunk/pypy/module/zipimport/interp_zipimport.py	Sun Apr 19 20:28:49 2009
@@ -137,10 +137,16 @@
             filename = filename.replace(os.path.sep, ZIPSEP)
         return filename
 
+    def corr_zname(self, fname):
+        if ZIPSEP != os.path.sep:
+            return fname.replace(ZIPSEP, os.path.sep)
+        else:
+            return fname
+
     def import_py_file(self, space, modname, filename, buf, pkgpath):
         w = space.wrap
         w_mod = w(Module(space, w(modname)))
-        real_name = self.name + os.path.sep + filename
+        real_name = self.name + os.path.sep + self.corr_zname(filename)
         space.setattr(w_mod, w('__loader__'), space.wrap(self))
         importing._prepare_module(space, w_mod, real_name, pkgpath)
         result = importing.load_source_module(space, w(modname), w_mod,
@@ -187,7 +193,7 @@
                                        pkgpath)
         buf = buf[8:] # XXX ugly copy, should use sequential read instead
         w_mod = w(Module(space, w(modname)))
-        real_name = self.name + os.path.sep + filename
+        real_name = self.name + os.path.sep + self.corr_zname(filename)
         space.setattr(w_mod, w('__loader__'), space.wrap(self))
         importing._prepare_module(space, w_mod, real_name, pkgpath)
         result = importing.load_compiled_module(space, w(modname), w_mod,



More information about the Pypy-commit mailing list