[pypy-svn] r72087 - in pypy/trunk/pypy: config doc/config interpreter interpreter/test jit/tl
benjamin at codespeak.net
benjamin at codespeak.net
Thu Mar 11 00:47:14 CET 2010
Author: benjamin
Date: Thu Mar 11 00:47:12 2010
New Revision: 72087
Removed:
pypy/trunk/pypy/doc/config/objspace.compiler.txt
pypy/trunk/pypy/doc/config/objspace.parser.txt
Modified:
pypy/trunk/pypy/config/pypyoption.py
pypy/trunk/pypy/interpreter/baseobjspace.py
pypy/trunk/pypy/interpreter/pycompiler.py
pypy/trunk/pypy/interpreter/test/test_compiler.py
pypy/trunk/pypy/interpreter/test/test_interpreter.py
pypy/trunk/pypy/jit/tl/pypyjit.py
Log:
remove CPythonCompiler
Our compiler is good enough nowdays, and it's annoying to maintain the CPython
interface.
Also remove the useless objspace.parser option.
Modified: pypy/trunk/pypy/config/pypyoption.py
==============================================================================
--- pypy/trunk/pypy/config/pypyoption.py (original)
+++ pypy/trunk/pypy/config/pypyoption.py Thu Mar 11 00:47:12 2010
@@ -107,14 +107,6 @@
"std",
cmdline='--objspace -o'),
- ChoiceOption("parser", "which parser to use for app-level code",
- ["pypy", "cpython"], "pypy",
- cmdline='--parser'),
-
- ChoiceOption("compiler", "which compiler to use for app-level code",
- ["cpython", "ast"], "ast",
- cmdline='--compiler'),
-
OptionDescription("opcodes", "opcodes to enable in the interpreter", [
BoolOption("CALL_LIKELY_BUILTIN", "emit a special bytecode for likely calls to builtin functions",
default=False,
Modified: pypy/trunk/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/trunk/pypy/interpreter/baseobjspace.py (original)
+++ pypy/trunk/pypy/interpreter/baseobjspace.py Thu Mar 11 00:47:12 2010
@@ -2,7 +2,7 @@
from pypy.interpreter.executioncontext import UserDelAction, FrameTraceAction
from pypy.interpreter.error import OperationError, operationerrfmt
from pypy.interpreter.argument import Arguments
-from pypy.interpreter.pycompiler import CPythonCompiler, PythonAstCompiler
+from pypy.interpreter.pycompiler import PythonAstCompiler
from pypy.interpreter.miscutils import ThreadLocals
from pypy.tool.cache import Cache
from pypy.tool.uid import HUGEVAL_BYTES
@@ -569,13 +569,7 @@
try:
return self.default_compiler
except AttributeError:
- if self.config.objspace.compiler == 'cpython':
- compiler = CPythonCompiler(self)
- elif self.config.objspace.compiler == 'ast':
- compiler = PythonAstCompiler(self)
- else:
- raise ValueError('unknown --compiler option value: %r' % (
- self.config.objspace.compiler,))
+ compiler = PythonAstCompiler(self)
self.default_compiler = compiler
return compiler
Modified: pypy/trunk/pypy/interpreter/pycompiler.py
==============================================================================
--- pypy/trunk/pypy/interpreter/pycompiler.py (original)
+++ pypy/trunk/pypy/interpreter/pycompiler.py Thu Mar 11 00:47:12 2010
@@ -76,31 +76,6 @@
return None # two different errors, expect more
-# ____________________________________________________________
-# faked compiler
-
-import warnings
-
-## from pypy.tool import stdlib___future__
-## compiler_flags = 0
-## compiler_features = {}
-## for fname in stdlib___future__.all_feature_names:
-## flag = getattr(stdlib___future__, fname).compiler_flag
-## compiler_flags |= flag
-## compiler_features[fname] = flag
-## allowed_flags = compiler_flags | PyCF_DONT_IMPLY_DEDENT
-
-## def get_flag_names(space, flags):
-## if flags & ~allowed_flags:
-## raise OperationError(space.w_ValueError,
-## space.wrap("compile(): unrecognized flags"))
-## flag_names = []
-## for name, value in compiler_features.items():
-## if flags & value:
-## flag_names.append( name )
-## return flag_names
-
-
class PyCodeCompiler(AbstractCompiler):
"""Base class for compilers producing PyCode objects."""
@@ -113,98 +88,6 @@
else:
return 0
-from pypy.interpreter.pyparser import future
-
-class CPythonCompiler(PyCodeCompiler):
- """Faked implementation of a compiler, using the underlying compile()."""
-
- def __init__(self, space):
- self.space = space
- self.w_compile_hook = space.w_None
- if sys.version_info >= (2.5):
- self.compiler_flags = future.futureFlags_2_5.allowed_flags
- else:
- self.compiler_flags = future.futureFlags_2_4.allowed_flags
-
- def compile(self, source, filename, mode, flags):
- space = self.space
- try:
- old = self.setup_warn_explicit(warnings)
- try:
- c = compile(source, filename, mode, flags, True)
- finally:
- self.restore_warn_explicit(warnings, old)
- # It would be nice to propagate all exceptions to app level,
- # but here we only propagate the 'usual' ones, until we figure
- # out how to do it generically.
- except SyntaxError,e:
- w_synerr = space.newtuple([space.wrap(e.msg),
- space.newtuple([space.wrap(e.filename),
- space.wrap(e.lineno),
- space.wrap(e.offset),
- space.wrap(e.text)])])
- raise OperationError(space.w_SyntaxError, w_synerr)
- except UnicodeDecodeError, e:
- # TODO use a custom UnicodeError
- raise OperationError(space.w_UnicodeDecodeError, space.newtuple([
- space.wrap(e.encoding), space.wrap(e.object),
- space.wrap(e.start),
- space.wrap(e.end), space.wrap(e.reason)]))
- except ValueError, e:
- raise OperationError(space.w_ValueError, space.wrap(str(e)))
- except TypeError, e:
- raise OperationError(space.w_TypeError, space.wrap(str(e)))
- from pypy.interpreter.pycode import PyCode
- return PyCode._from_code(space, c)
- compile._annspecialcase_ = "override:cpy_compile"
-
- def _warn_explicit(self, message, category, filename, lineno,
- module=None, registry=None):
- if hasattr(category, '__bases__') and \
- issubclass(category, SyntaxWarning):
- assert isinstance(message, str)
- space = self.space
- w_mod = space.sys.getmodule('warnings')
- if w_mod is not None:
- w_dict = w_mod.getdict()
- w_reg = space.call_method(w_dict, 'setdefault',
- space.wrap("__warningregistry__"),
- space.newdict())
- try:
- space.call_method(w_mod, 'warn_explicit',
- space.wrap(message),
- space.w_SyntaxWarning,
- space.wrap(filename),
- space.wrap(lineno),
- space.w_None,
- space.w_None)
- except OperationError, e:
- if e.match(space, space.w_SyntaxWarning):
- raise OperationError(
- space.w_SyntaxError,
- space.wrap(message))
- raise
-
- def setup_warn_explicit(self, warnings):
- """
- this is a hack until we have our own parsing/compiling
- in place: we bridge certain warnings to the applevel
- warnings module to let it decide what to do with
- a syntax warning ...
- """
- # there is a hack to make the flow space happy:
- # 'warnings' should not look like a Constant
- old_warn_explicit = warnings.warn_explicit
- warnings.warn_explicit = self._warn_explicit
- return old_warn_explicit
-
- def restore_warn_explicit(self, warnings, old_warn_explicit):
- warnings.warn_explicit = old_warn_explicit
-
-
-
-########
-
class PythonAstCompiler(PyCodeCompiler):
"""Uses the stdlib's python implementation of compiler
@@ -217,6 +100,7 @@
def __init__(self, space, override_version=None):
from pypy.interpreter.pyparser.pyparse import PythonParser
+ from pypy.interpreter.pyparser import future
PyCodeCompiler.__init__(self, space)
self.parser = PythonParser(space)
self.additional_rules = {}
Modified: pypy/trunk/pypy/interpreter/test/test_compiler.py
==============================================================================
--- pypy/trunk/pypy/interpreter/test/test_compiler.py (original)
+++ pypy/trunk/pypy/interpreter/test/test_compiler.py Thu Mar 11 00:47:12 2010
@@ -1,6 +1,6 @@
import __future__
import py, sys
-from pypy.interpreter.pycompiler import CPythonCompiler, PythonAstCompiler
+from pypy.interpreter.pycompiler import PythonAstCompiler
from pypy.interpreter.pycode import PyCode
from pypy.interpreter.error import OperationError
from pypy.interpreter.argument import Arguments
@@ -637,25 +637,6 @@
assert 'hello_world' in space.str_w(space.str(ex.get_w_value(space)))
-class TestPyCCompiler(BaseTestCompiler):
- def setup_method(self, method):
- self.compiler = CPythonCompiler(self.space)
-
- if sys.version_info < (2, 5):
- def skip_on_2_4(self):
- py.test.skip("syntax not supported by the CPython 2.4 compiler")
- _unicode_error_kind = "w_UnicodeError"
- test_continue_in_nested_finally = skip_on_2_4
- test_try_except_finally = skip_on_2_4
- test_yield_in_finally = skip_on_2_4
- elif sys.version_info < (2, 6):
- _unicode_error_kind = "w_UnicodeDecodeError"
- else:
- def skip_on_2_6(self):
- py.test.skip("syntax different on CPython 2.6 compiler")
- test_globals_warnings = skip_on_2_6
- _unicode_error_kind = "w_SyntaxError"
-
class TestPythonAstCompiler_25_grammar(BaseTestCompiler):
def setup_method(self, method):
self.compiler = PythonAstCompiler(self.space, "2.5")
Modified: pypy/trunk/pypy/interpreter/test/test_interpreter.py
==============================================================================
--- pypy/trunk/pypy/interpreter/test/test_interpreter.py (original)
+++ pypy/trunk/pypy/interpreter/test/test_interpreter.py Thu Mar 11 00:47:12 2010
@@ -2,7 +2,6 @@
import sys
class TestInterpreter:
- from pypy.interpreter.pycompiler import CPythonCompiler as CompilerClass
def codetest(self, source, functionname, args):
"""Compile and run the given code string, and then call its function
@@ -34,15 +33,6 @@
else:
return space.unwrap(w_output)
- def setup_method(self, arg):
- ec = self.space.getexecutioncontext()
- self.saved_compiler = ec.compiler
- ec.compiler = self.CompilerClass(self.space)
-
- def teardown_method(self, arg):
- ec = self.space.getexecutioncontext()
- ec.compiler = self.saved_compiler
-
def test_exception_trivial(self):
x = self.codetest('''\
def f():
@@ -166,26 +156,6 @@
'''
self.codetest(code, 'f', [])
- def test_extended_arg(self):
- longexpr = 'x = x or ' + '-x' * 2500
- code = '''
- def f(x):
- %s
- %s
- %s
- %s
- %s
- %s
- %s
- %s
- %s
- %s
- while x:
- x -= 1 # EXTENDED_ARG is for the JUMP_ABSOLUTE at the end of the loop
- return x
- ''' % ((longexpr,)*10)
- assert self.codetest(code, 'f', [3]) == 0
-
def test_call_star_starstar(self):
code = '''\
def f1(n):
@@ -261,14 +231,6 @@
assert self.codetest(code, 'f', []) == os.name
-class TestPyPyInterpreter(TestInterpreter):
- """Runs the previous test with the pypy parser"""
- from pypy.interpreter.pycompiler import PythonAstCompiler as CompilerClass
-
- def test_extended_arg(self):
- py.test.skip("expression too large for the recursive parser")
-
-
class AppTestInterpreter:
def test_trivial(self):
x = 42
Modified: pypy/trunk/pypy/jit/tl/pypyjit.py
==============================================================================
--- pypy/trunk/pypy/jit/tl/pypyjit.py (original)
+++ pypy/trunk/pypy/jit/tl/pypyjit.py Thu Mar 11 00:47:12 2010
@@ -33,7 +33,6 @@
config.translation.backendopt.inline_threshold = 0
config.translation.gc = 'boehm'
config.objspace.nofaking = True
-config.objspace.compiler = "ast"
config.translating = True
set_opt_level(config, level='jit')
config.objspace.allworkingmodules = False
More information about the Pypy-commit
mailing list