[pypy-commit] pypy default: (alex, fijal): remove some random nonsense

alex_gaynor noreply at buildbot.pypy.org
Fri Mar 22 05:35:04 CET 2013


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: 
Changeset: r62634:ecebd2bc6598
Date: 2013-03-21 21:34 -0700
http://bitbucket.org/pypy/pypy/changeset/ecebd2bc6598/

Log:	(alex, fijal): remove some random nonsense

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1,27 +1,30 @@
 import sys
 
+from rpython.rlib.cache import Cache
+from rpython.tool.uid import HUGEVAL_BYTES
+from rpython.rlib import jit, types
+from rpython.rlib.debug import make_sure_not_resized
+from rpython.rlib.objectmodel import (we_are_translated, newlist_hint,
+     compute_unique_id)
+from rpython.rlib.signature import signature
+from rpython.rlib.rarithmetic import r_uint
+
 from pypy.interpreter.executioncontext import (ExecutionContext, ActionFlag,
     UserDelAction, FrameTraceAction)
 from pypy.interpreter.error import (OperationError, operationerrfmt,
     new_exception_class, typed_unwrap_error_msg)
 from pypy.interpreter.argument import Arguments
 from pypy.interpreter.miscutils import ThreadLocals
-from rpython.rlib.cache import Cache
-from rpython.tool.uid import HUGEVAL_BYTES
-from rpython.rlib import jit
-from rpython.rlib.debug import make_sure_not_resized
-from rpython.rlib.objectmodel import we_are_translated, newlist_hint,\
-     compute_unique_id
-from rpython.rlib.rarithmetic import r_uint
 
 
 __all__ = ['ObjSpace', 'OperationError', 'Wrappable', 'W_Root']
 
 UINT_MAX_32_BITS = r_uint(4294967295)
 
-unpackiterable_driver = jit.JitDriver(name = 'unpackiterable',
-                                      greens = ['tp'],
-                                      reds = ['items', 'w_iterator'])
+unpackiterable_driver = jit.JitDriver(name='unpackiterable',
+                                      greens=['tp'],
+                                      reds=['items', 'w_iterator'])
+
 
 class W_Root(object):
     """This is the abstract root class of all wrapped objects that live
@@ -698,6 +701,7 @@
                 raise
             return None
 
+    @signature(types.bool(), returns=types.instance(W_Root))
     def newbool(self, b):
         if b:
             return self.w_True
diff --git a/pypy/tool/ann_override.py b/pypy/tool/ann_override.py
--- a/pypy/tool/ann_override.py
+++ b/pypy/tool/ann_override.py
@@ -1,22 +1,17 @@
 # overrides for annotation specific to PyPy codebase
-from rpython.annotator.policy import AnnotatorPolicy, Sig
+from rpython.annotator.policy import AnnotatorPolicy
 # for some reason, model must be imported first,
 # or we create a cycle.
 from rpython.flowspace.model import Constant
-from rpython.annotator import model as annmodel
-from rpython.annotator.bookkeeper import getbookkeeper
 from rpython.annotator import specialize
-from pypy.interpreter import baseobjspace
+
 
 def isidentifier(s):
-    if not s: return False
+    if not s:
+        return False
     s = s.replace('_', 'x')
     return s[0].isalpha() and s.isalnum()
 
-# patch - mostly for debugging, to enforce some signatures
-baseobjspace.ObjSpace.newbool.im_func._annenforceargs_ = Sig(lambda s1,s2: s1,
-                                                             bool)
-
 
 class PyPyAnnotatorPolicy(AnnotatorPolicy):
     def __init__(pol, single_space=None):
@@ -60,8 +55,8 @@
         # for jit benefit
         if cached not in t._immutable_fields_: # accessed this way just
                                                # for convenience
-            t._immutable_fields_.append(cached)        
-    
+            t._immutable_fields_.append(cached)
+
     def attach_lookup(pol, t, attr):
         cached = "cached_%s" % attr
         if not t.is_heaptype() and not t.is_cpytype():
diff --git a/rpython/rlib/signature.py b/rpython/rlib/signature.py
--- a/rpython/rlib/signature.py
+++ b/rpython/rlib/signature.py
@@ -1,5 +1,6 @@
 from rpython.rlib import types
 
+
 def signature(*paramtypes, **kwargs):
     """Decorate a function to specify its type signature.
 
@@ -12,7 +13,7 @@
     """
     returntype = kwargs.pop('returns', None)
     if returntype is None:
-        raise TypeError, "signature: parameter 'returns' required"
+        raise TypeError("signature: parameter 'returns' required")
 
     def decorator(f):
         f._signature_ = (paramtypes, returntype)
diff --git a/rpython/rlib/types.py b/rpython/rlib/types.py
--- a/rpython/rlib/types.py
+++ b/rpython/rlib/types.py
@@ -10,9 +10,11 @@
 def float():
     return model.SomeFloat()
 
+
 def singlefloat():
     return model.SomeSingleFloat()
 
+
 def longfloat():
     return model.SomeLongFloat()
 
@@ -21,18 +23,26 @@
     return model.SomeInteger()
 
 
+def bool():
+    return model.SomeBool()
+
+
 def unicode():
     return model.SomeUnicodeString()
 
+
 def unicode0():
     return model.SomeUnicodeString(no_nul=True)
 
+
 def str():
     return model.SomeString()
 
+
 def str0():
     return model.SomeString(no_nul=True)
 
+
 def char():
     return model.SomeChar()
 
@@ -46,21 +56,25 @@
     listdef = ListDef(None, element, mutated=True, resized=True)
     return model.SomeList(listdef)
 
+
 def array(element):
     listdef = ListDef(None, element, mutated=True, resized=False)
     return model.SomeList(listdef)
 
+
 def dict(keytype, valuetype):
     dictdef = DictDef(None, keytype, valuetype)
     return model.SomeDict(dictdef)
 
 
-def instance(class_):
-    return lambda bookkeeper: model.SomeInstance(bookkeeper.getuniqueclassdef(class_))
+def instance(cls):
+    return lambda bookkeeper: model.SomeInstance(bookkeeper.getuniqueclassdef(cls))
+
 
 class SelfTypeMarker(object):
     pass
 
+
 def self():
     return SelfTypeMarker()
 
@@ -68,5 +82,6 @@
 class AnyTypeMarker(object):
     pass
 
+
 def any():
     return AnyTypeMarker()


More information about the pypy-commit mailing list