[pypy-svn] r47689 - pypy/dist/pypy/module/__builtin__

fijal at codespeak.net fijal at codespeak.net
Sun Oct 21 23:55:39 CEST 2007


Author: fijal
Date: Sun Oct 21 23:55:39 2007
New Revision: 47689

Modified:
   pypy/dist/pypy/module/__builtin__/__init__.py
Log:
Startup hook for zipimport. No tests as zipimport is not here.


Modified: pypy/dist/pypy/module/__builtin__/__init__.py
==============================================================================
--- pypy/dist/pypy/module/__builtin__/__init__.py	(original)
+++ pypy/dist/pypy/module/__builtin__/__init__.py	Sun Oct 21 23:55:39 2007
@@ -166,3 +166,20 @@
                 # xxx hide the installer
                 space.delitem(self.w_dict, space.wrap(name))
                 del self.loaders[name]
+
+    def startup(self, space):
+        # install zipimport hook
+        try:
+            w_import = space.builtin.get('__import__')
+            w_zipimport = space.call(w_import, space.newlist(
+                [space.wrap('zipimport')]))
+        except OperationError, e:
+            if not e.match(space, space.w_ImportError):
+                raise
+        else:
+            w_sys = space.getbuiltinmodule('sys')
+            w_path_hooks = space.getattr(w_sys, space.wrap('path_hooks'))
+            w_append = space.getattr(w_path_hooks, space.wrap('append'))
+            w_zipimporter = space.getattr(w_zipimport,
+                                          space.wrap('zipimporter'))
+            space.call(w_append, space.newlist([w_zipimporter]))



More information about the Pypy-commit mailing list