[pypy-svn] r49256 - pypy/dist/pypy/translator/goal
xoraxax at codespeak.net
xoraxax at codespeak.net
Sat Dec 1 19:14:39 CET 2007
Author: xoraxax
Date: Sat Dec 1 19:14:39 2007
New Revision: 49256
Modified:
pypy/dist/pypy/translator/goal/app_main.py
pypy/dist/pypy/translator/goal/nanos.py
Log:
app_main does not use the normal os module now anymore. Nanos can expose its module even in scenarios without a pypy interpreter - this makes app_main testable again. This should fix the broken -u option.
Modified: pypy/dist/pypy/translator/goal/app_main.py
==============================================================================
--- pypy/dist/pypy/translator/goal/app_main.py (original)
+++ pypy/dist/pypy/translator/goal/app_main.py Sat Dec 1 19:14:39 2007
@@ -401,8 +401,8 @@
if __name__ == '__main__':
- import os
import autopath
+ import nanos
# obscure! try removing the following line, see how it crashes, and
# guess why...
ImStillAroundDontForgetMe = sys.modules['__main__']
@@ -420,5 +420,6 @@
from pypy.module.sys.version import PYPY_VERSION
sys.pypy_version_info = PYPY_VERSION
sys.pypy_initial_path = pypy_initial_path
+ os = nanos.os_module_for_testing
sys.exit(entry_point(sys.argv[0], sys.argv[1:], os))
#sys.exit(entry_point('app_main.py', sys.argv[1:]))
Modified: pypy/dist/pypy/translator/goal/nanos.py
==============================================================================
--- pypy/dist/pypy/translator/goal/nanos.py (original)
+++ pypy/dist/pypy/translator/goal/nanos.py Sat Dec 1 19:14:39 2007
@@ -35,7 +35,7 @@
app_os = applevel(r'''
# NOT_RPYTHON
- from os import sep, pathsep
+ from os import sep, pathsep, getenv, name, fdopen
try:
from os import readlink
except ImportError:
@@ -53,3 +53,14 @@
space.setattr(w_os, space.wrap('path'), w_os_path)
space.setattr(w_os, space.wrap('getenv'), space.wrap(getenv_w))
return w_os
+
+
+# in order to be able to test app_main without the pypy interpreter
+# we create the nanos module with the same names here like it would
+# be created while translation
+path_module_for_testing = type(os)("os.path")
+os_module_for_testing = type(os)("os")
+os_module_for_testing.path = path_module_for_testing
+eval(app_os_path.code, path_module_for_testing.__dict__)
+eval(app_os.code, os_module_for_testing.__dict__)
+
More information about the pypy-svn
mailing list