[pypy-svn] r15100 - pypy/dist/pypy/module/__builtin__
rxe at codespeak.net
rxe at codespeak.net
Tue Jul 26 12:51:05 CEST 2005
Author: rxe
Date: Tue Jul 26 12:51:04 2005
New Revision: 15100
Modified:
pypy/dist/pypy/module/__builtin__/importing.py
Log:
Add a create_module() helper to importing.
Modified: pypy/dist/pypy/module/__builtin__/importing.py
==============================================================================
--- pypy/dist/pypy/module/__builtin__/importing.py (original)
+++ pypy/dist/pypy/module/__builtin__/importing.py Tue Jul 26 12:51:04 2005
@@ -14,17 +14,13 @@
# XXX a frozen version of some routines of only one of the
# XXX posixpath/ntpath/macpath modules.
-
def try_import_mod(space, w_modulename, fn, w_parent, w_name, pkgdir=None):
- w = space.wrap
if os.path.exists(fn):
- w_mod = space.wrap(Module(space, w_modulename))
- space.sys.setmodule(w_mod)
- space.setattr(w_mod, w('__file__'), w(fn))
- space.setattr(w_mod, w('__doc__'), space.w_None)
- if pkgdir is not None:
- space.setattr(w_mod, w('__path__'), space.newlist([w(pkgdir)]))
- w_dict = space.getattr(w_mod, w('__dict__'))
+ w_mod, w_dict = create_module(space,
+ w_modulename,
+ space.wrap(fn),
+ pkgdir)
+
e = None
try:
imp_execfile(space, fn, w_dict, w_dict)
@@ -217,6 +213,18 @@
space.wrap(space.builtin))
pycode.exec_code(space, w_globals, w_locals)
+def create_module(space, w_modulename, w_name, pkgdir):
+ """ Helper to create module. """
+ w = space.wrap
+ w_mod = w(Module(space, w_modulename))
+ space.sys.setmodule(w_mod)
+ space.setattr(w_mod, w('__file__'), w_name)
+ space.setattr(w_mod, w('__doc__'), space.w_None)
+ if pkgdir is not None:
+ space.setattr(w_mod, w('__path__'), space.newlist([w(pkgdir)]))
+ w_dict = space.getattr(w_mod, w('__dict__'))
+ return w_mod, w_dict
+
# __________________________________________________________________
#
# .pyc file support
More information about the Pypy-commit
mailing list