[pypy-svn] r77578 - in pypy/branch/minor-cleanup/pypy: annotation annotation/test module/sys objspace/std rpython rpython/test translator/goal

arigo at codespeak.net arigo at codespeak.net
Mon Oct 4 16:51:59 CEST 2010


Author: arigo
Date: Mon Oct  4 16:51:57 2010
New Revision: 77578

Removed:
   pypy/branch/minor-cleanup/pypy/rpython/rspecialcase.py
   pypy/branch/minor-cleanup/pypy/rpython/test/test_rspecialcase.py
Modified:
   pypy/branch/minor-cleanup/pypy/annotation/policy.py
   pypy/branch/minor-cleanup/pypy/annotation/test/test_annrpython.py
   pypy/branch/minor-cleanup/pypy/module/sys/__init__.py
   pypy/branch/minor-cleanup/pypy/module/sys/state.py
   pypy/branch/minor-cleanup/pypy/objspace/std/fake.py
   pypy/branch/minor-cleanup/pypy/objspace/std/objspace.py
   pypy/branch/minor-cleanup/pypy/rpython/rtyper.py
   pypy/branch/minor-cleanup/pypy/translator/goal/ann_override.py
Log:
Kill an old way to do specialization at the annotator level.


Modified: pypy/branch/minor-cleanup/pypy/annotation/policy.py
==============================================================================
--- pypy/branch/minor-cleanup/pypy/annotation/policy.py	(original)
+++ pypy/branch/minor-cleanup/pypy/annotation/policy.py	Mon Oct  4 16:51:57 2010
@@ -1,4 +1,4 @@
-# base annotation policy for overrides and specialization
+# base annotation policy for specialization
 from pypy.annotation.specialize import default_specialize as default
 from pypy.annotation.specialize import specialize_argvalue, specialize_argtype, specialize_arglistitemtype
 from pypy.annotation.specialize import memo
@@ -41,7 +41,7 @@
         if directive is None:
             return pol.default_specialize
 
-        # specialize|override:name[(args)]
+        # specialize[(args)]
         directive_parts = directive.split('(', 1)
         if len(directive_parts) == 1:
             [name] = directive_parts
@@ -60,14 +60,6 @@
         except AttributeError:
             raise AttributeError("%r specialize tag not defined in annotation"
                                  "policy %s" % (name, pol))
-        if directive.startswith('override:'):
-            # different signature: override__xyz(*args_s)
-            if parms:
-                raise Exception, "override:* specialisations don't support parameters"
-            def specialize_override(funcdesc, args_s):
-                funcdesc.overridden = True
-                return specializer(*args_s)
-            return specialize_override
         else:
             if not parms:
                 return specializer
@@ -92,9 +84,5 @@
         from pypy.rpython.annlowlevel import LowLevelAnnotatorPolicy
         return LowLevelAnnotatorPolicy.specialize__ll_and_arg(*args)
 
-    def override__ignore(pol, *args):
-        bk = getbookkeeper()
-        return bk.immutablevalue(None)
-
 class StrictAnnotatorPolicy(AnnotatorPolicy):
     allow_someobjects = False

Modified: pypy/branch/minor-cleanup/pypy/annotation/test/test_annrpython.py
==============================================================================
--- pypy/branch/minor-cleanup/pypy/annotation/test/test_annrpython.py	(original)
+++ pypy/branch/minor-cleanup/pypy/annotation/test/test_annrpython.py	Mon Oct  4 16:51:57 2010
@@ -766,28 +766,6 @@
         s = a.build_types(f, [list])
         assert s.classdef is a.bookkeeper.getuniqueclassdef(IndexError)  # KeyError ignored because l is a list
 
-    def test_overrides(self):
-        excs = []
-        def record_exc(e):
-            """NOT_RPYTHON"""
-            excs.append(sys.exc_info)
-        record_exc._annspecialcase_ = "override:record_exc"
-        def g():
-            pass
-        def f():
-            try:
-                g()
-            except Exception, e:
-                record_exc(e)
-        class MyAnnotatorPolicy(policy.AnnotatorPolicy):
-
-            def override__record_exc(pol, s_e):
-                return a.bookkeeper.immutablevalue(None)
-            
-        a = self.RPythonAnnotator(policy=MyAnnotatorPolicy())
-        s = a.build_types(f, [])
-        assert s.const is None
-
     def test_freeze_protocol(self):
         class Stuff:
             def __init__(self, flag):

Modified: pypy/branch/minor-cleanup/pypy/module/sys/__init__.py
==============================================================================
--- pypy/branch/minor-cleanup/pypy/module/sys/__init__.py	(original)
+++ pypy/branch/minor-cleanup/pypy/module/sys/__init__.py	Mon Oct  4 16:51:57 2010
@@ -7,13 +7,15 @@
     """Sys Builtin Module. """
     def __init__(self, space, w_name):
         """NOT_RPYTHON""" # because parent __init__ isn't
+        if space.config.translating:
+            del self.__class__.interpleveldefs['pypy_getudir']
         super(Module, self).__init__(space, w_name) 
         self.checkinterval = 100
         self.recursionlimit = 100
         self.w_default_encoder = None
         self.defaultencoding = "ascii"
         self.filesystemencoding = None
-        
+
     interpleveldefs = {
         '__name__'              : '(space.wrap("sys"))', 
         '__doc__'               : '(space.wrap("PyPy sys module"))', 
@@ -37,7 +39,7 @@
         'argv'                  : 'state.get(space).w_argv', 
         'warnoptions'           : 'state.get(space).w_warnoptions', 
         'builtin_module_names'  : 'state.w_None',
-        'pypy_getudir'          : 'state.pypy_getudir', 
+        'pypy_getudir'          : 'state.pypy_getudir',    # not translated
         'pypy_initial_path'     : 'state.pypy_initial_path',
 
         '_getframe'             : 'vm._getframe', 

Modified: pypy/branch/minor-cleanup/pypy/module/sys/state.py
==============================================================================
--- pypy/branch/minor-cleanup/pypy/module/sys/state.py	(original)
+++ pypy/branch/minor-cleanup/pypy/module/sys/state.py	Mon Oct  4 16:51:57 2010
@@ -95,15 +95,8 @@
 def getio(space):
     return space.fromcache(IOState)
 
-def _pypy_getudir(space):
-    """NOT_RPYTHON"""
+def pypy_getudir(space):
+    """NOT_RPYTHON
+    (should be removed from interpleveldefs before translation)"""
     from pypy.tool.udir import udir
     return space.wrap(str(udir))
-_pypy_getudir._annspecialcase_ = "override:ignore"
-
-# we need the indirection because this function will live in a dictionary with other 
-# RPYTHON functions and share call sites with them. Better it not be a special-case
-# directly. 
-def pypy_getudir(space):
-    return _pypy_getudir(space)
-

Modified: pypy/branch/minor-cleanup/pypy/objspace/std/fake.py
==============================================================================
--- pypy/branch/minor-cleanup/pypy/objspace/std/fake.py	(original)
+++ pypy/branch/minor-cleanup/pypy/objspace/std/fake.py	Mon Oct  4 16:51:57 2010
@@ -21,7 +21,6 @@
     #debug_print("faking obj %s" % x)
     ft = fake_type(type(x))
     return ft(space, x)
-fake_object._annspecialcase_ = "override:fake_object"
 
 import sys
 
@@ -47,7 +46,6 @@
         w_exc = space.wrap(exc)
         w_value = space.wrap(value)
     raise OperationError, OperationError(w_exc, w_value), tb
-wrap_exception._annspecialcase_ = "override:ignore"
 
 def fake_type(cpy_type):
     assert type(cpy_type) is type

Modified: pypy/branch/minor-cleanup/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/branch/minor-cleanup/pypy/objspace/std/objspace.py	(original)
+++ pypy/branch/minor-cleanup/pypy/objspace/std/objspace.py	Mon Oct  4 16:51:57 2010
@@ -242,7 +242,6 @@
             w_result = getattr(self, 'w_' + x.__name__)
             return w_result
         return None
-    wrap_exception_cls._annspecialcase_ = "override:wrap_exception_cls"
 
     def unwrap(self, w_obj):
         if isinstance(w_obj, Wrappable):

Modified: pypy/branch/minor-cleanup/pypy/rpython/rtyper.py
==============================================================================
--- pypy/branch/minor-cleanup/pypy/rpython/rtyper.py	(original)
+++ pypy/branch/minor-cleanup/pypy/rpython/rtyper.py	Mon Oct  4 16:51:57 2010
@@ -421,7 +421,7 @@
             assert noexclink.exitcase is None
             if pos == "removed":
                 # the exception cannot actually occur at all.
-                # See for example rspecialcase.rtype_call_specialcase().
+                # This is set by calling exception_cannot_occur().
                 # We just remove all exception links.
                 block.exitswitch = None
                 block.exits = block.exits[:1]
@@ -1019,7 +1019,7 @@
 from pypy.rpython import rint, rbool, rfloat
 from pypy.rpython import rrange
 from pypy.rpython import rstr, rdict, rlist
-from pypy.rpython import rclass, rbuiltin, rpbc, rspecialcase
+from pypy.rpython import rclass, rbuiltin, rpbc
 from pypy.rpython import rexternalobj
 from pypy.rpython import rptr
 from pypy.rpython import rgeneric

Modified: pypy/branch/minor-cleanup/pypy/translator/goal/ann_override.py
==============================================================================
--- pypy/branch/minor-cleanup/pypy/translator/goal/ann_override.py	(original)
+++ pypy/branch/minor-cleanup/pypy/translator/goal/ann_override.py	Mon Oct  4 16:51:57 2010
@@ -27,21 +27,6 @@
         pol.pypytypes = {}
         pol.single_space = single_space
 
-    #def override__wrap_exception_cls(pol, space, x):
-    #    import pypy.objspace.std.typeobject as typeobject
-    #    clsdef = getbookkeeper().getuniqueclassdef(typeobject.W_TypeObject)
-    #    return annmodel.SomeInstance(clsdef, can_be_None=True)
-    #
-    #def override__fake_object(pol, space, x):
-    #    from pypy.interpreter import typedef
-    #    clsdef = getbookkeeper().getuniqueclassdef(typedef.W_Root)
-    #    return annmodel.SomeInstance(clsdef)    
-    #
-    #def override__cpy_compile(pol, self, source, filename, mode, flags):
-    #    from pypy.interpreter import pycode
-    #    clsdef = getbookkeeper().getuniqueclassdef(pycode.PyCode)
-    #    return annmodel.SomeInstance(clsdef)    
-
     def specialize__wrap(pol,  funcdesc, args_s):
         from pypy.interpreter.baseobjspace import Wrappable
         from pypy.annotation.classdef import ClassDef



More information about the Pypy-commit mailing list