[pypy-svn] r75081 - in pypy/branch/fast-forward/pypy: module/sys module/sys/test translator/goal
benjamin at codespeak.net
benjamin at codespeak.net
Thu Jun 3 23:02:34 CEST 2010
Author: benjamin
Date: Thu Jun 3 23:02:32 2010
New Revision: 75081
Modified:
pypy/branch/fast-forward/pypy/module/sys/__init__.py
pypy/branch/fast-forward/pypy/module/sys/app.py
pypy/branch/fast-forward/pypy/module/sys/test/test_sysmodule.py
pypy/branch/fast-forward/pypy/translator/goal/app_main.py
Log:
when translated, set sys.flags in app_main
Modified: pypy/branch/fast-forward/pypy/module/sys/__init__.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/sys/__init__.py (original)
+++ pypy/branch/fast-forward/pypy/module/sys/__init__.py Thu Jun 3 23:02:32 2010
@@ -33,9 +33,9 @@
# to the trunk of a checkout or to the dir /usr/share/pypy-1.1 .
'path' : 'state.get(space).w_path',
- 'py3kwarning' : 'space.w_False', # for now
'modules' : 'state.get(space).w_modules',
- 'argv' : 'state.get(space).w_argv',
+ 'argv' : 'state.get(space).w_argv',
+ 'py3kwarning' : 'space.w_False',
'warnoptions' : 'state.get(space).w_warnoptions',
'builtin_module_names' : 'state.w_None',
'pypy_getudir' : 'state.pypy_getudir',
@@ -84,7 +84,8 @@
'exit' : 'app.exit',
'exitfunc' : 'app.exitfunc',
'callstats' : 'app.callstats',
- 'copyright' : 'app.copyright_str',
+ 'copyright' : 'app.copyright_str',
+ 'flags' : 'app.null_sysflags',
}
def setbuiltinmodule(self, w_module, name):
Modified: pypy/branch/fast-forward/pypy/module/sys/app.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/sys/app.py (original)
+++ pypy/branch/fast-forward/pypy/module/sys/app.py Thu Jun 3 23:02:32 2010
@@ -3,7 +3,7 @@
The 'sys' module.
"""
-import sys
+from pypy.lib._structseq import structseqtype, structseqfield
def excepthook(exctype, value, traceback):
"""Handle an exception by displaying it with a traceback on sys.stderr."""
@@ -47,3 +47,26 @@
Portions Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.
All Rights Reserved.
"""
+
+
+# This is tested in test_app_main.py
+class sysflags:
+ __metaclass__ = structseqtype
+
+ debug = structseqfield(0)
+ py3k_warning = structseqfield(1)
+ division_warning = structseqfield(2)
+ division_new = structseqfield(3)
+ inspect = structseqfield(4)
+ interactive = structseqfield(5)
+ optimize = structseqfield(6)
+ dont_write_bytecode = structseqfield(7)
+ no_user_site = structseqfield(8)
+ no_site = structseqfield(9)
+ ignore_environment = structseqfield(10)
+ tabcheck = structseqfield(11)
+ verbose = structseqfield(12)
+ unicode = structseqfield(13)
+ bytes_warning = structseqfield(14)
+
+null_sysflags = sysflags((0,)*15)
Modified: pypy/branch/fast-forward/pypy/module/sys/test/test_sysmodule.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/sys/test/test_sysmodule.py (original)
+++ pypy/branch/fast-forward/pypy/module/sys/test/test_sysmodule.py Thu Jun 3 23:02:32 2010
@@ -27,10 +27,6 @@
cls.w_appdirect = cls.space.wrap(option.runappdirect)
cls.w_filesystemenc = cls.space.wrap(sys.getfilesystemencoding())
- def test_sys_py3kwarning(self):
- import sys
- assert not sys.py3kwarning
-
def test_sys_in_modules(self):
import sys
modules = sys.modules
Modified: pypy/branch/fast-forward/pypy/translator/goal/app_main.py
==============================================================================
--- pypy/branch/fast-forward/pypy/translator/goal/app_main.py (original)
+++ pypy/branch/fast-forward/pypy/translator/goal/app_main.py Thu Jun 3 23:02:32 2010
@@ -235,22 +235,29 @@
_seen[dir] = True
return executable
-
-default_options = dict.fromkeys((
+# Order is significant!
+sys_flags = (
"debug",
"py3k_warning",
+ "division_warning",
+ "division_new",
"inspect",
"interactive",
"optimize",
+ "dont_write_bytecode",
"no_user_site",
- "ignore_environment",
"no_site",
+ "ignore_environment",
"tabcheck",
"verbose",
"unicode",
"bytes_warning",
- "dont_write_bytecode",
- "run_command",
+)
+
+
+default_options = dict.fromkeys(
+ sys_flags +
+ ("run_command",
"run_module",
"run_stdin",
"warnoptions",
@@ -354,6 +361,10 @@
if isinstance(value, int)]
"(%s)" % (", ".join(flag_opts),)
print flag_opts
+ if we_are_translated():
+ flags = [options[flag] for flag in sys_flags]
+ sys.flags = type(sys.flags)(flags)
+ sys.py3kwarning = sys.flags.py3k_warning
return options
def run_command_line(interactive,
More information about the Pypy-commit
mailing list