[pypy-svn] r73138 - in pypy/branch/cleanup-objspace-init/pypy/objspace/std: . test

benjamin at codespeak.net benjamin at codespeak.net
Mon Mar 29 23:47:25 CEST 2010


Author: benjamin
Date: Mon Mar 29 23:47:23 2010
New Revision: 73138

Modified:
   pypy/branch/cleanup-objspace-init/pypy/objspace/std/booltype.py
   pypy/branch/cleanup-objspace-init/pypy/objspace/std/complextype.py
   pypy/branch/cleanup-objspace-init/pypy/objspace/std/dictproxytype.py
   pypy/branch/cleanup-objspace-init/pypy/objspace/std/dicttype.py
   pypy/branch/cleanup-objspace-init/pypy/objspace/std/floattype.py
   pypy/branch/cleanup-objspace-init/pypy/objspace/std/frozensettype.py
   pypy/branch/cleanup-objspace-init/pypy/objspace/std/inttype.py
   pypy/branch/cleanup-objspace-init/pypy/objspace/std/itertype.py
   pypy/branch/cleanup-objspace-init/pypy/objspace/std/listtype.py
   pypy/branch/cleanup-objspace-init/pypy/objspace/std/longtype.py
   pypy/branch/cleanup-objspace-init/pypy/objspace/std/nonetype.py
   pypy/branch/cleanup-objspace-init/pypy/objspace/std/objecttype.py
   pypy/branch/cleanup-objspace-init/pypy/objspace/std/settype.py
   pypy/branch/cleanup-objspace-init/pypy/objspace/std/slicetype.py
   pypy/branch/cleanup-objspace-init/pypy/objspace/std/stdtypedef.py
   pypy/branch/cleanup-objspace-init/pypy/objspace/std/stringtype.py
   pypy/branch/cleanup-objspace-init/pypy/objspace/std/test/test_typeobject.py
   pypy/branch/cleanup-objspace-init/pypy/objspace/std/tupletype.py
   pypy/branch/cleanup-objspace-init/pypy/objspace/std/typetype.py
   pypy/branch/cleanup-objspace-init/pypy/objspace/std/unicodetype.py
Log:
cleanup type definition files

* remove stdtypedef.newmethod
* import things from their actual location
* some whitespace cleanup


Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/booltype.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/booltype.py	(original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/booltype.py	Mon Mar 29 23:47:23 2010
@@ -1,4 +1,5 @@
-from pypy.objspace.std.stdtypedef import *
+from pypy.interpreter import gateway
+from pypy.objspace.std.stdtypedef import StdTypeDef
 from pypy.objspace.std.inttype import int_typedef
 
 def descr__new__(space, w_booltype, w_obj=None):
@@ -16,6 +17,6 @@
 Returns True when the argument x is true, False otherwise.
 The builtins True and False are the only two instances of the class bool.
 The class bool is a subclass of the class int, and cannot be subclassed.''',
-    __new__ = newmethod(descr__new__),
+    __new__ = gateway.interp2app(descr__new__),
     )
 bool_typedef.acceptable_as_base_class = False

Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/complextype.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/complextype.py	(original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/complextype.py	Mon Mar 29 23:47:23 2010
@@ -1,9 +1,9 @@
-from pypy.interpreter.error import OperationError
 from pypy.interpreter import gateway
+from pypy.interpreter.error import OperationError
 from pypy.objspace.std.register_all import register_all
 from pypy.objspace.std.strutil import interp_string_to_float, ParseStringError
 from pypy.objspace.std.noneobject import W_NoneObject
-from pypy.objspace.std.stdtypedef import GetSetProperty, StdTypeDef, newmethod
+from pypy.objspace.std.stdtypedef import GetSetProperty, StdTypeDef
 from pypy.objspace.std.stdtypedef import StdObjSpaceMultiMethod
 
 # ERRORCODES
@@ -36,7 +36,7 @@
     # extract first number
     realstart = i
     pc = s[i]
-    while i < slen and s[i] != ' ': 
+    while i < slen and s[i] != ' ':
         if s[i] in ('+','-') and pc not in ('e','E') and i != realstart:
             break
         pc = s[i]
@@ -136,8 +136,9 @@
         except ParseStringError:
             raise OperationError(space.w_ValueError, space.wrap(ERR_MALFORMED))
         else:
-            #check for overflow            
-            if abs(realval) == OVERFLOWED_FLOAT or abs(imagval) == OVERFLOWED_FLOAT:
+            # check for overflow
+            if (abs(realval) == OVERFLOWED_FLOAT or
+                abs(imagval) == OVERFLOWED_FLOAT):
                 raise OperationError(space.w_ValueError,space.wrap(
                                     "complex() literal too large to convert"))
 
@@ -156,8 +157,8 @@
             w_real = space.call_function(w_method)
             # __complex__() could return a string, which space.float()
             # could accept below...  Let's catch this case.
-            if space.is_true(space.isinstance(w_imag, space.w_str)) or \
-                   space.is_true(space.isinstance(w_imag, space.w_unicode)):
+            if (space.is_true(space.isinstance(w_imag, space.w_str)) or
+                space.is_true(space.isinstance(w_imag, space.w_unicode))):
                 raise OperationError(space.w_TypeError,
                                      space.wrap("__complex__() cannot return"
                                                 " a string"))
@@ -205,19 +206,19 @@
                                  space.wrap("descriptor is for 'complex'"))
         return space.newfloat(getattr(w_obj, name))
     return GetSetProperty(fget)
-    
+
 def descr___getnewargs__(space,  w_self):
     from pypy.objspace.std.complexobject import W_ComplexObject
     assert isinstance(w_self, W_ComplexObject)
-    return space.newtuple([space.newcomplex(w_self.realval,w_self.imagval)]) 
-    
+    return space.newtuple([space.newcomplex(w_self.realval,w_self.imagval)])
+
 complex_typedef = StdTypeDef("complex",
     __doc__ = """complex(real[, imag]) -> complex number
-        
+
 Create a complex number from a real part and an optional imaginary part.
 This is equivalent to (real + imag*1j) where imag defaults to 0.""",
-    __new__ = newmethod(descr__new__),
-    __getnewargs__ = newmethod(descr___getnewargs__),
+    __new__ = gateway.interp2app(descr__new__),
+    __getnewargs__ = gateway.interp2app(descr___getnewargs__),
     real = complexwprop('realval'),
     imag = complexwprop('imagval'),
     )

Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/dictproxytype.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/dictproxytype.py	(original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/dictproxytype.py	Mon Mar 29 23:47:23 2010
@@ -1,5 +1,7 @@
-from pypy.objspace.std.stdtypedef import *
+from pypy.interpreter import gateway
+from pypy.interpreter.typedef import GetSetProperty
 from pypy.interpreter.error import OperationError
+from pypy.objspace.std.stdtypedef import StdTypeDef
 
 # ____________________________________________________________
 

Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/dicttype.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/dicttype.py	(original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/dicttype.py	Mon Mar 29 23:47:23 2010
@@ -1,7 +1,8 @@
 from pypy.interpreter.baseobjspace import ObjSpace, W_Root
 from pypy.interpreter.error import OperationError
+from pypy.interpreter.mixedmodule import MixedModule
 from pypy.interpreter import gateway
-from pypy.objspace.std.stdtypedef import *
+from pypy.objspace.std.stdtypedef import StdTypeDef, SMM, no_hash_descr
 from pypy.objspace.std.register_all import register_all
 from pypy.interpreter.error import OperationError
 
@@ -176,8 +177,10 @@
         d[k] = v
 dict(**kwargs) -> new dictionary initialized with the name=value pairs
     in the keyword argument list.  For example:  dict(one=1, two=2)''',
-    __new__ = newmethod(descr__new__,
-                        unwrap_spec=[gateway.ObjSpace,gateway.W_Root,gateway.Arguments]),
+    __new__ = gateway.interp2app(descr__new__,
+                                 unwrap_spec=
+                                 [gateway.ObjSpace,
+                                  gateway.W_Root,gateway.Arguments]),
     __hash__ = no_hash_descr,
     fromkeys = gateway.interp2app(descr_fromkeys, as_classmethod=True),
     )
@@ -200,18 +203,16 @@
     XXX to do: remove this __reduce__ method and do
     a registration with copy_reg, instead.
     """
-    from pypy.interpreter.mixedmodule import MixedModule
     w_mod    = space.getbuiltinmodule('_pickle_support')
     mod      = space.interp_w(MixedModule, w_mod)
     new_inst = mod.get('dictiter_surrogate_new')
     w_typeobj = space.gettypeobject(dictiter_typedef)
-    
-    from pypy.interpreter.mixedmodule import MixedModule
+
     raise OperationError(
         space.w_RuntimeError,
         space.wrap("cannot pickle dictiters with multidicts"))
     # XXXXXX get that working again
-    
+
     # we cannot call __init__ since we don't have the original dict
     if isinstance(w_self, W_DictIter_Keys):
         w_clone = space.allocate_instance(W_DictIter_Keys, w_typeobj)
@@ -237,7 +238,7 @@
         w_res
     ]
     w_ret = space.newtuple([new_inst, space.newtuple(tup)])
-    return w_ret    
+    return w_ret
 
 # ____________________________________________________________
 

Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/floattype.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/floattype.py	(original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/floattype.py	Mon Mar 29 23:47:23 2010
@@ -1,5 +1,6 @@
-from pypy.objspace.std.stdtypedef import *
+from pypy.interpreter import gateway
 from pypy.interpreter.error import OperationError
+from pypy.objspace.std.stdtypedef import StdTypeDef
 from pypy.objspace.std.strutil import string_to_float, ParseStringError
 from pypy.objspace.std.strutil import interp_string_to_float
 
@@ -48,5 +49,5 @@
     __doc__ = '''float(x) -> floating point number
 
 Convert a string or number to a floating point number, if possible.''',
-    __new__ = newmethod(descr__new__),
+    __new__ = gateway.interp2app(descr__new__),
     )

Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/frozensettype.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/frozensettype.py	(original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/frozensettype.py	Mon Mar 29 23:47:23 2010
@@ -1,9 +1,8 @@
+from pypy.interpreter import gateway
 from pypy.interpreter.error import OperationError
 from pypy.objspace.std.register_all import register_all
-from pypy.objspace.std.stdtypedef import StdTypeDef, newmethod
-from pypy.objspace.std.stdtypedef import SMM
-from pypy.interpreter.gateway import NoneNotWrapped
-from pypy.interpreter import gateway
+from pypy.objspace.std.stdtypedef import StdTypeDef, SMM
+
 
 frozenset_copy                  = SMM('copy', 1,
                                       doc='Return a shallow copy of a set.')
@@ -37,7 +36,8 @@
 
 register_all(vars(), globals())
 
-def descr__frozenset__new__(space, w_frozensettype, w_iterable=NoneNotWrapped):
+def descr__frozenset__new__(space, w_frozensettype,
+                            w_iterable=gateway.NoneNotWrapped):
     from pypy.objspace.std.setobject import W_FrozensetObject
     from pypy.objspace.std.setobject import _is_frozenset_exact
     if (space.is_w(w_frozensettype, space.w_frozenset) and
@@ -52,7 +52,7 @@
     __doc__ = """frozenset(iterable) --> frozenset object
 
 Build an immutable unordered collection.""",
-    __new__ = newmethod(descr__frozenset__new__),
+    __new__ = gateway.interp2app(descr__frozenset__new__),
     )
 
 frozenset_typedef.registermethods(globals())

Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/inttype.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/inttype.py	(original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/inttype.py	Mon Mar 29 23:47:23 2010
@@ -1,7 +1,9 @@
-from pypy.objspace.std.stdtypedef import *
-from pypy.objspace.std.strutil import string_to_int, string_to_w_long, ParseStringError, ParseStringOverflowError
+from pypy.interpreter import gateway
 from pypy.interpreter.error import OperationError
-from pypy.interpreter.gateway import NoneNotWrapped
+from pypy.objspace.std.stdtypedef import StdTypeDef
+from pypy.objspace.std.strutil import (string_to_int, string_to_w_long,
+                                       ParseStringError,
+                                       ParseStringOverflowError)
 from pypy.rlib.rarithmetic import r_uint
 from pypy.rlib.objectmodel import instantiate
 
@@ -47,8 +49,8 @@
     except ParseStringError, e:
         raise OperationError(space.w_ValueError,
                              space.wrap(e.msg))
-    
-def descr__new__(space, w_inttype, w_x=0, w_base=NoneNotWrapped):
+
+def descr__new__(space, w_inttype, w_x=0, w_base=gateway.NoneNotWrapped):
     from pypy.objspace.std.intobject import W_IntObject
     w_longval = None
     w_value = w_x     # 'x' is the keyword argument name in CPython
@@ -64,7 +66,7 @@
                 raise OperationError(space.w_ValueError,
                                      space.wrap(e.msg))
             except ParseStringOverflowError, e:
-                 w_longval = retry_to_w_long(space, e.parser)                
+                 w_longval = retry_to_w_long(space, e.parser)
         elif space.is_true(space.isinstance(w_value, space.w_unicode)):
             if space.config.objspace.std.withropeunicode:
                 from pypy.objspace.std.ropeunicodeobject import unicode_to_decimal_w
@@ -77,7 +79,7 @@
                 raise OperationError(space.w_ValueError,
                                      space.wrap(e.msg))
             except ParseStringOverflowError, e:
-                 w_longval = retry_to_w_long(space, e.parser)                
+                 w_longval = retry_to_w_long(space, e.parser)
         else:
             # otherwise, use the __int__() method
             w_obj = space.int(w_value)
@@ -116,13 +118,13 @@
             raise OperationError(space.w_ValueError,
                                  space.wrap(e.msg))
         except ParseStringOverflowError, e:
-            w_longval = retry_to_w_long(space, e.parser, base)                        
+            w_longval = retry_to_w_long(space, e.parser, base)
 
     if w_longval is not None:
         if not space.is_w(w_inttype, space.w_int):
             raise OperationError(space.w_OverflowError,
                                  space.wrap(
-                "long int too large to convert to int"))          
+                "long int too large to convert to int"))
         return w_longval
     elif space.is_w(w_inttype, space.w_int):
         # common case
@@ -143,5 +145,5 @@
 the optional base.  It is an error to supply a base when converting a
 non-string. If the argument is outside the integer range a long object
 will be returned instead.''',
-    __new__ = newmethod(descr__new__),
+    __new__ = gateway.interp2app(descr__new__),
     )

Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/itertype.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/itertype.py	(original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/itertype.py	Mon Mar 29 23:47:23 2010
@@ -1,4 +1,5 @@
-from pypy.objspace.std.stdtypedef import *
+from pypy.interpreter import gateway
+from pypy.objspace.std.stdtypedef import StdTypeDef
 
 # ____________________________________________________________
 

Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/listtype.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/listtype.py	(original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/listtype.py	Mon Mar 29 23:47:23 2010
@@ -1,6 +1,6 @@
 from pypy.interpreter import gateway
 from pypy.interpreter.error import OperationError
-from pypy.objspace.std.stdtypedef import *
+from pypy.objspace.std.stdtypedef import StdTypeDef, SMM, no_hash_descr
 from pypy.objspace.std.register_all import register_all
 from sys import maxint
 
@@ -24,7 +24,8 @@
                         ' occurrences of value')
 list_reverse  = SMM('reverse',1,
                     doc='L.reverse() -- reverse *IN PLACE*')
-list_sort     = SMM('sort',   4, defaults=(None, None, False), argnames=['cmp', 'key', 'reverse'],
+list_sort     = SMM('sort',   4, defaults=(None, None, False),
+                    argnames=['cmp', 'key', 'reverse'],
                     doc='L.sort(cmp=None, key=None, reverse=False) -- stable'
                         ' sort *IN PLACE*;\ncmp(x, y) -> -1, 0, 1')
 list_reversed = SMM('__reversed__', 1,
@@ -50,9 +51,9 @@
 list_typedef = StdTypeDef("list",
     __doc__ = '''list() -> new list
 list(sequence) -> new list initialized from sequence's items''',
-    __new__ = newmethod(descr__new__, unwrap_spec=[gateway.ObjSpace,
-                                                   gateway.W_Root,
-                                                   gateway.Arguments]),
+    __new__ = gateway.interp2app(descr__new__, unwrap_spec=[gateway.ObjSpace,
+                                               gateway.W_Root,
+                                               gateway.Arguments]),
     __hash__ = no_hash_descr,
     )
 list_typedef.registermethods(globals())

Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/longtype.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/longtype.py	(original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/longtype.py	Mon Mar 29 23:47:23 2010
@@ -1,9 +1,9 @@
-from pypy.objspace.std.stdtypedef import *
-from pypy.objspace.std.strutil import string_to_w_long, ParseStringError
 from pypy.interpreter.error import OperationError
-from pypy.interpreter.gateway import NoneNotWrapped
+from pypy.interpreter import gateway
+from pypy.objspace.std.stdtypedef import StdTypeDef
+from pypy.objspace.std.strutil import string_to_w_long, ParseStringError
 
-def descr__new__(space, w_longtype, w_x=0, w_base=NoneNotWrapped):
+def descr__new__(space, w_longtype, w_x=0, w_base=gateway.NoneNotWrapped):
     from pypy.objspace.std.longobject import W_LongObject
     w_value = w_x     # 'x' is the keyword argument name in CPython
     if w_base is None:
@@ -75,5 +75,5 @@
 string representation of a floating point number!)  When converting a
 string, use the optional base.  It is an error to supply a base when
 converting a non-string.''',
-    __new__ = newmethod(descr__new__),
+    __new__ = gateway.interp2app(descr__new__),
     )

Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/nonetype.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/nonetype.py	(original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/nonetype.py	Mon Mar 29 23:47:23 2010
@@ -1,4 +1,4 @@
-from pypy.objspace.std.stdtypedef import *
+from pypy.objspace.std.stdtypedef import StdTypeDef
 
 
 # ____________________________________________________________

Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/objecttype.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/objecttype.py	(original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/objecttype.py	Mon Mar 29 23:47:23 2010
@@ -1,9 +1,8 @@
 from pypy.interpreter.error import OperationError, operationerrfmt
-from pypy.interpreter.typedef import GetSetProperty
-from pypy.objspace.descroperation import Object
+from pypy.interpreter.typedef import GetSetProperty, default_identity_hash
 from pypy.interpreter import gateway
-from pypy.interpreter.typedef import default_identity_hash
-from pypy.objspace.std.stdtypedef import StdTypeDef, newmethod
+from pypy.objspace.descroperation import Object
+from pypy.objspace.std.stdtypedef import StdTypeDef, no_hash_descr
 from pypy.objspace.std.register_all import register_all
 
 
@@ -171,8 +170,8 @@
     __repr__ = gateway.interp2app(descr__repr__),
     __class__ = GetSetProperty(descr__class__, descr_set___class__),
     __doc__ = '''The most base type''',
-    __new__ = newmethod(descr__new__,
-                        unwrap_spec = [gateway.ObjSpace,gateway.W_Root,gateway.Arguments]),
+    __new__ = gateway.interp2app(descr__new__,
+    unwrap_spec = [gateway.ObjSpace,gateway.W_Root,gateway.Arguments]),
     __hash__ = gateway.interp2app(default_identity_hash),
     __reduce_ex__ = gateway.interp2app(descr__reduce_ex__,
                                   unwrap_spec=[gateway.ObjSpace,gateway.W_Root,int]),

Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/settype.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/settype.py	(original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/settype.py	Mon Mar 29 23:47:23 2010
@@ -1,8 +1,7 @@
 from pypy.interpreter.error import OperationError
+from pypy.interpreter import gateway
 from pypy.objspace.std.register_all import register_all
-from pypy.objspace.std.stdtypedef import StdTypeDef, newmethod, no_hash_descr
-from pypy.objspace.std.stdtypedef import SMM
-from pypy.interpreter.gateway import NoneNotWrapped
+from pypy.objspace.std.stdtypedef import StdTypeDef, no_hash_descr, SMM
 from pypy.interpreter import gateway
 
 set_add                         = SMM('add', 2,
@@ -77,9 +76,9 @@
     __doc__ = """set(iterable) --> set object
 
 Build an unordered collection.""",
-    __new__ = newmethod(descr__new__, unwrap_spec=[gateway.ObjSpace,
-                                                   gateway.W_Root,
-                                                   gateway.Arguments]),
+    __new__ = gateway.interp2app(descr__new__, unwrap_spec=[gateway.ObjSpace,
+                                                            gateway.W_Root,
+                                                            gateway.Arguments]),
     __hash__ = no_hash_descr,
     )
 

Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/slicetype.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/slicetype.py	(original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/slicetype.py	Mon Mar 29 23:47:23 2010
@@ -1,6 +1,6 @@
-import sys
-from pypy.interpreter import baseobjspace
-from pypy.objspace.std.stdtypedef import *
+from pypy.interpreter import baseobjspace, gateway
+from pypy.interpreter.typedef import GetSetProperty
+from pypy.objspace.std.stdtypedef import StdTypeDef, SMM, no_hash_descr
 from pypy.objspace.std.register_all import register_all
 from pypy.interpreter.error import OperationError
 
@@ -88,7 +88,7 @@
     __doc__ = '''slice([start,] stop[, step])
 
 Create a slice object.  This is used for extended slicing (e.g. a[0:10:2]).''',
-    __new__ = newmethod(descr__new__),
+    __new__ = gateway.interp2app(descr__new__),
     __hash__ = no_hash_descr,
     start = slicewprop('w_start'),
     stop  = slicewprop('w_stop'),

Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/stdtypedef.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/stdtypedef.py	(original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/stdtypedef.py	Mon Mar 29 23:47:23 2010
@@ -10,9 +10,7 @@
 from pypy.rlib import jit
 from pypy.tool.sourcetools import compile2
 
-__all__ = ['StdTypeDef', 'newmethod', 'gateway',
-           'GetSetProperty', 'Member',
-           'SMM', 'descr_get_dict', 'no_hash_descr']
+__all__ = ['StdTypeDef', 'SMM', 'no_hash_descr']
 
 SMM = StdObjSpaceMultiMethod
 
@@ -43,11 +41,6 @@
 std_dict_descr = GetSetProperty(descr_get_dict, descr_set_dict, descr_del_dict)
 std_dict_descr.name = '__dict__'
 
-def newmethod(descr_new, unwrap_spec=None):
-    "NOT_RPYTHON: initialization-time only."
-    # this is turned into a static method by the constructor of W_TypeObject.
-    return gateway.interp2app(descr_new, unwrap_spec=unwrap_spec)
-
 # ____________________________________________________________
 #
 # All the code below fishes from the multimethod registration tables

Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/stringtype.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/stringtype.py	(original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/stringtype.py	Mon Mar 29 23:47:23 2010
@@ -1,4 +1,5 @@
-from pypy.objspace.std.stdtypedef import *
+from pypy.interpreter import gateway
+from pypy.objspace.std.stdtypedef import StdTypeDef, SMM
 from pypy.objspace.std.basestringtype import basestring_typedef
 
 from sys import maxint
@@ -42,7 +43,7 @@
 
 def sliced(space, s, start, stop, orig_obj):
     assert start >= 0
-    assert stop >= 0 
+    assert stop >= 0
     assert not space.config.objspace.std.withrope
     if start == 0 and stop == len(s) and space.is_w(space.type(orig_obj), space.w_str):
         return orig_obj
@@ -294,7 +295,7 @@
 # ____________________________________________________________
 
 str_typedef = StdTypeDef("str", basestring_typedef,
-    __new__ = newmethod(descr__new__),
+    __new__ = gateway.interp2app(descr__new__),
     __doc__ = '''str(object) -> string
 
 Return a nice string representation of the object.
@@ -326,4 +327,3 @@
         if u_self[start+i] != prefix[i]:
             return False
     return True
-    

Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/test/test_typeobject.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/test/test_typeobject.py	(original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/test/test_typeobject.py	Mon Mar 29 23:47:23 2010
@@ -1,5 +1,5 @@
 from pypy.objspace.std.model import W_Object
-from pypy.objspace.std.stdtypedef import StdTypeDef, newmethod
+from pypy.objspace.std.stdtypedef import StdTypeDef
 from pypy.conftest import gettestobjspace
 
 from pypy.objspace.std.typeobject import W_TypeObject
@@ -15,7 +15,7 @@
         def descr__new__(space, w_subtype):
             return space.allocate_instance(W_Stuff, w_subtype)
         W_Stuff.typedef = StdTypeDef("stuff",
-                                     __new__ = newmethod(descr__new__))
+                                     __new__ = interp2app(descr__new__))
         W_Stuff.typedef.acceptable_as_base_class = False
         w_stufftype = space.gettypeobject(W_Stuff.typedef)
         space.appexec([w_stufftype], """(stufftype):

Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/tupletype.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/tupletype.py	(original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/tupletype.py	Mon Mar 29 23:47:23 2010
@@ -1,11 +1,11 @@
-from pypy.objspace.std.stdtypedef import *
-from pypy.interpreter.gateway import NoneNotWrapped
+from pypy.interpreter import gateway
+from pypy.objspace.std.stdtypedef import StdTypeDef
 
 def wraptuple(space, list_w):
     from pypy.objspace.std.tupleobject import W_TupleObject
     return W_TupleObject(list_w)
 
-def descr__new__(space, w_tupletype, w_sequence=NoneNotWrapped):
+def descr__new__(space, w_tupletype, w_sequence=gateway.NoneNotWrapped):
     from pypy.objspace.std.tupleobject import W_TupleObject
     if w_sequence is None:
         tuple_w = []
@@ -25,5 +25,5 @@
 tuple(sequence) -> tuple initialized from sequence's items
 
 If the argument is a tuple, the return value is the same object.''',
-    __new__ = newmethod(descr__new__),
+    __new__ = gateway.interp2app(descr__new__),
     )

Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/typetype.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/typetype.py	(original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/typetype.py	Mon Mar 29 23:47:23 2010
@@ -1,8 +1,9 @@
 from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.interpreter import gateway
 from pypy.interpreter.argument import Arguments
-from pypy.interpreter.typedef import weakref_descr
-from pypy.objspace.std.stdtypedef import *
+from pypy.interpreter.typedef import (GetSetProperty, descr_get_dict,
+                                      weakref_descr)
+from pypy.objspace.std.stdtypedef import StdTypeDef
 
 def descr__new__(space, w_typetype, w_name, w_bases, w_dict):
     "This is used to create user-defined classes only."
@@ -10,7 +11,7 @@
     # XXX check types
 
     w_typetype = _precheck_for_new(space, w_typetype)
-    
+
     bases_w = space.fixedview(w_bases)
 
     w_winner = w_typetype
@@ -34,7 +35,7 @@
         if not space.is_w(newfunc, space.getattr(space.w_type, space.wrap('__new__'))):
             return space.call_function(newfunc, w_winner, w_name, w_bases, w_dict)
         w_typetype = w_winner
-        
+
     name = space.str_w(w_name)
     assert isinstance(name, str)
     dict_w = {}
@@ -187,7 +188,7 @@
         return space.get(w_result, space.w_None, w_type)
 
 def descr__flags(space, w_type):
-    w_type = _check(space, w_type)    
+    w_type = _check(space, w_type)
     return space.wrap(w_type.__flags__)
 
 def descr_get__module(space, w_type):
@@ -195,9 +196,9 @@
     return w_type.get_module()
 
 def descr_set__module(space, w_type, w_value):
-    w_type = _check(space, w_type)    
+    w_type = _check(space, w_type)
     if not w_type.is_heaptype():
-        raise operationerrfmt(space.w_TypeError, 
+        raise operationerrfmt(space.w_TypeError,
                               "can't set %s.__module__",
                               w_type.name)
     w_type.mutated()
@@ -211,7 +212,7 @@
 # ____________________________________________________________
 
 type_typedef = StdTypeDef("type",
-    __new__ = newmethod(descr__new__),
+    __new__ = gateway.interp2app(descr__new__),
     __name__ = GetSetProperty(descr_get__name__, descr_set__name__),
     __bases__ = GetSetProperty(descr_get__bases__, descr_set__bases__),
     __base__ = GetSetProperty(descr__base),

Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/unicodetype.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/unicodetype.py	(original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/unicodetype.py	Mon Mar 29 23:47:23 2010
@@ -1,8 +1,8 @@
+from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.interpreter import gateway
-from pypy.objspace.std.stdtypedef import *
+from pypy.objspace.std.stdtypedef import StdTypeDef, SMM
 from pypy.objspace.std.register_all import register_all
 from pypy.objspace.std.basestringtype import basestring_typedef
-from pypy.interpreter.error import OperationError, operationerrfmt
 
 from sys import maxint
 
@@ -286,7 +286,7 @@
 # ____________________________________________________________
 
 unicode_typedef = StdTypeDef("unicode", basestring_typedef,
-    __new__ = newmethod(descr_new_),
+    __new__ = gateway.interp2app(descr_new_),
     __doc__ = '''unicode(string [, encoding[, errors]]) -> object
 
 Create a new Unicode object from the given encoded string.



More information about the Pypy-commit mailing list