[pypy-svn] r46896 - in pypy/dist/pypy: bin config lib/pyontology/test objspace/std objspace/std/test translator/goal
xoraxax at codespeak.net
xoraxax at codespeak.net
Wed Sep 26 13:42:03 CEST 2007
Author: xoraxax
Date: Wed Sep 26 13:42:02 2007
New Revision: 46896
Modified:
pypy/dist/pypy/bin/py.py
pypy/dist/pypy/config/pypyoption.py
pypy/dist/pypy/lib/pyontology/test/test_sparql.py
pypy/dist/pypy/objspace/std/objspace.py
pypy/dist/pypy/objspace/std/test/test_index.py
pypy/dist/pypy/translator/goal/app_main.py
pypy/dist/pypy/translator/goal/targetpypystandalone.py
Log:
Move the oldstyle translation option to py.py and app_main.py to make it setable at runtime.
Modified: pypy/dist/pypy/bin/py.py
==============================================================================
--- pypy/dist/pypy/bin/py.py (original)
+++ pypy/dist/pypy/bin/py.py Wed Sep 26 13:42:02 2007
@@ -37,6 +37,9 @@
StrOption("runcommand",
"program passed in as CMD (terminates option list)",
default=None, cmdline="-c"),
+ BoolOption("oldstyle_classes",
+ "Use old-style classes by default.",
+ default=False, cmdline="-k --oldstyle"),
])
pypy_init = gateway.applevel('''
@@ -73,11 +76,9 @@
space = option.make_objspace(config)
space._starttime = starttime
- #assert 'pypy.tool.udir' not in sys.modules, (
- # "running py.py should not import pypy.tool.udir, which is\n"
- # "only for testing or translating purposes.")
- # ^^^ _socket and other rctypes-based modules need udir
- space.setitem(space.sys.w_dict,space.wrap('executable'),space.wrap(argv[0]))
+ space.setitem(space.sys.w_dict, space.wrap('executable'), space.wrap(argv[0]))
+ if interactiveconfig.oldstyle_classes:
+ space.setitem(space.builtin.w_dict, space.wrap('__metaclass__'), space.w_classobj)
# store the command-line arguments into sys.argv
go_interactive = interactiveconfig.interactive
Modified: pypy/dist/pypy/config/pypyoption.py
==============================================================================
--- pypy/dist/pypy/config/pypyoption.py (original)
+++ pypy/dist/pypy/config/pypyoption.py Wed Sep 26 13:42:02 2007
@@ -235,10 +235,6 @@
"special case the 'list[integer]' expressions",
default=False),
- BoolOption("oldstyle",
- "specify whether the default metaclass should be classobj",
- default=False, cmdline="--oldstyle"),
-
BoolOption("logspaceoptypes",
"a instrumentation option: before exit, print the types seen by "
"certain simpler bytecodes",
Modified: pypy/dist/pypy/lib/pyontology/test/test_sparql.py
==============================================================================
--- pypy/dist/pypy/lib/pyontology/test/test_sparql.py (original)
+++ pypy/dist/pypy/lib/pyontology/test/test_sparql.py Wed Sep 26 13:42:02 2007
@@ -500,4 +500,4 @@
if check_have_oldstyle():
TestXMLRPC = _TestXMLRPC
else:
- py.test.skip('Please build PyPy with --oldstyle, needed by xmlrpclib')
+ py.test.skip('Please run PyPy with --oldstyle, needed by xmlrpclib')
Modified: pypy/dist/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/dist/pypy/objspace/std/objspace.py (original)
+++ pypy/dist/pypy/objspace/std/objspace.py Wed Sep 26 13:42:02 2007
@@ -48,10 +48,6 @@
PACKAGE_PATH = 'objspace.std'
- def setoptions(self, **kwds):
- if "oldstyle" in kwds:
- self.config.objspace.std.oldstyle = kwds["oldstyle"]
-
def initialize(self):
"NOT_RPYTHON: only for initializing the space."
self._typecache = Cache()
@@ -253,11 +249,9 @@
""")
self.w_dict.__flags__ = old_flags
- if self.config.objspace.std.oldstyle:
- self.enable_old_style_classes_as_default_metaclass()
-
# final setup
self.setup_builtin_modules()
+
# Adding transparent proxy call
if self.config.objspace.std.withtproxy:
w___pypy__ = self.getbuiltinmodule("__pypy__")
@@ -268,16 +262,7 @@
self.setattr(w___pypy__, self.wrap('get_tproxy_controller'),
self.wrap(app_proxy_controller))
- def enable_old_style_classes_as_default_metaclass(self):
- self.setitem(self.builtin.w_dict, self.wrap('__metaclass__'), self.w_classobj)
- def enable_new_style_classes_as_default_metaclass(self):
- space = self
- try:
- self.delitem(self.builtin.w_dict, self.wrap('__metaclass__'))
- except OperationError, e:
- if not e.match(space, space.w_KeyError):
- raise
def setup_old_style_classes(self):
"""NOT_RPYTHON"""
@@ -292,6 +277,9 @@
self.w_classobj = w_classobj
self.w_instance = w_instance
+ def force_old_style_classes(self):
+ self.setitem(self.builtin.w_dict, self.wrap('__metaclass__'), self.w_classobj)
+
def create_builtin_module(self, pyname, publicname):
"""NOT_RPYTHON
helper function which returns the wrapped module and its dict.
Modified: pypy/dist/pypy/objspace/std/test/test_index.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_index.py (original)
+++ pypy/dist/pypy/objspace/std/test/test_index.py Wed Sep 26 13:42:02 2007
@@ -3,7 +3,9 @@
class AppTest_IndexProtocol:
def setup_class(self):
- self.space = gettestobjspace(oldstyle=True)
+ self.space = gettestobjspace()
+ self.space.force_old_style_classes()
+
w_oldstyle = self.space.appexec([], """():
class oldstyle:
def __index__(self):
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 Wed Sep 26 13:42:02 2007
@@ -3,15 +3,16 @@
# See test/test_app_main.
"""
options:
- -i inspect interactively after running script
- -O dummy optimization flag for compatibility with C Python
- -c CMD program passed in as CMD (terminates option list)
- -S do not 'import site' on initialization
- -u unbuffered binary stdout and stderr
- -h, --help show this help message and exit
- -m library module to be run as a script (terminates option list)
- --version print the PyPy version
- --info print translation information about this PyPy executable
+ -i inspect interactively after running script
+ -O dummy optimization flag for compatibility with C Python
+ -c CMD program passed in as CMD (terminates option list)
+ -S do not 'import site' on initialization
+ -u unbuffered binary stdout and stderr
+ -h, --help show this help message and exit
+ -m library module to be run as a script (terminates option list)
+ -k, --oldstyle use old-style classes instead of newstyle classes everywhere
+ --version print the PyPy version
+ --info print translation information about this PyPy executable
"""
import sys, os
@@ -179,6 +180,7 @@
i = 0
run_module = False
run_stdin = False
+ oldstyle_classes = False
while i < len(argv):
arg = argv[i]
if not arg.startswith('-'):
@@ -216,6 +218,8 @@
return 2
run_module = True
break
+ elif arg in ('-k', '--oldstyle'):
+ oldstyle_classes = True
elif arg == '--':
i += 1
break # terminates option list
@@ -235,6 +239,10 @@
mainmodule = type(sys)('__main__')
sys.modules['__main__'] = mainmodule
+ if oldstyle_classes:
+ import __builtin__
+ __builtin__.__metaclass__ = __builtin__._classobj
+
if import_site:
try:
import site
Modified: pypy/dist/pypy/translator/goal/targetpypystandalone.py
==============================================================================
--- pypy/dist/pypy/translator/goal/targetpypystandalone.py (original)
+++ pypy/dist/pypy/translator/goal/targetpypystandalone.py Wed Sep 26 13:42:02 2007
@@ -170,10 +170,6 @@
def get_entry_point(self, config):
space = make_objspace(config)
- if not config.objspace.std.oldstyle:
- # disable translation of the whole of classobjinterp.py
- StdObjSpace.setup_old_style_classes = lambda self: None
-
# manually imports app_main.py
filename = os.path.join(this_dir, 'app_main.py')
w_dict = space.newdict()
More information about the Pypy-commit
mailing list