1. Pypy
  2. Untitled project
  3. pypy

Commits

Maciej Fijalkowski  committed 5a165e7

use newer shinier interface a bit everywhere

  • Participants
  • Parent commits 875dd99
  • Branches kill-someobject

Comments (0)

Files changed (30)

File pypy/interpreter/gateway.py

View file
  • Ignore whitespace
             if el[0] == 'INTERNAL:self':
                 self.visit_self(el[1], *args)
             else:
-                assert len(el) == 2    # 2nd arg is str that evals to 'default'
-                assert el[0] is W_Root    # for now
-                self.visit__W_Root(W_Root, *args)
+                assert False, "not supported any more, use WrappedDefault"
+        elif isinstance(el, WrappedDefault):
+            self.visit__W_Root(W_Root, *args)
         elif isinstance(el, type):
             for typ in self.bases_order:
                 if issubclass(el, typ):
                 if isinstance(el, tuple):
                     parts.append(''.join([getattr(subel, '__name__', subel)
                                           for subel in el]))
+                elif isinstance(el, WrappedDefault):
+                    parts.append('W_Root')
                 else:
                     parts.append(getattr(el, '__name__', el))
             label = '_'.join(parts)
         return func
     return decorator
 
+class WrappedDefault(object):
+    """ Can be used inside unwrap_spec as WrappedDefault(3) which means
+    it'll be treated as W_Root, but fed with default which will be a wrapped
+    argument to constructor.
+    """
+    def __init__(self, default_value):
+        self.default_value = default_value
 
 def build_unwrap_spec(func, argnames, self_type=None):
     """build the list of parameter unwrap spec for the function.
                 spec = code._unwrap_spec[i]
                 argname = code._argnames[i]
                 if isinstance(spec, tuple) and spec[0] is W_Root:
-                    w_default = eval(spec[1], {'space': space})
+                    assert False, "use WrappedDefault"
+                if isinstance(spec, WrappedDefault):
+                    w_default = eval('space.wrap(%r)' % (spec.default_value,),
+                                     {'space': space})
                     assert isinstance(w_default, W_Root)
                     assert argname.startswith('w_')
                     argname = argname[2:]

File pypy/interpreter/test/test_gateway.py

View file
  • Ignore whitespace
 
 from pypy.conftest import gettestobjspace
 from pypy.interpreter import gateway, argument
-from pypy.interpreter.gateway import ObjSpace, W_Root
+from pypy.interpreter.gateway import ObjSpace, W_Root, WrappedDefault
 import py
 import sys
 
 
     def test_unwrap_spec_default_applevel(self):
         space = self.space
-        @gateway.unwrap_spec(w_x = (W_Root, 'space.wrap(42)'))
+        @gateway.unwrap_spec(w_x = WrappedDefault(42))
         def g(space, w_x):
             return w_x
         w_g = space.wrap(gateway.interp2app_temp(g))
 
     def test_unwrap_spec_default_applevel_2(self):
         space = self.space
-        @gateway.unwrap_spec(w_x = (W_Root, 'space.wrap(42)'), y=int)
+        @gateway.unwrap_spec(w_x = (WrappedDefault(42)), y=int)
         def g(space, w_x, y=10):
             return space.add(w_x, space.wrap(y))
         w_g = space.wrap(gateway.interp2app_temp(g))
 
     def test_unwrap_spec_default_applevel_bogus(self):
         space = self.space
-        @gateway.unwrap_spec(w_x = (W_Root, 'space.wrap(42)'), y=int)
+        @gateway.unwrap_spec(w_x = WrappedDefault(42), y=int)
         def g(space, w_x, y):
             never_called
         py.test.raises(AssertionError, space.wrap, gateway.interp2app_temp(g))

File pypy/interpreter/typedef.py

View file
  • Ignore whitespace
 """
 import py
 from pypy.interpreter.gateway import interp2app, BuiltinCode, unwrap_spec,\
-     W_Root
+     WrappedDefault
 from pypy.interpreter.argument import Arguments
 from pypy.interpreter.baseobjspace import Wrappable, DescrMismatch
 from pypy.interpreter.error import OperationError, operationerrfmt
         self.objclass_getter = objclass_getter
         self.use_closure = use_closure
 
-    @unwrap_spec(w_cls = (W_Root, 'space.w_None'))
+    @unwrap_spec(w_cls = WrappedDefault(None))
     def descr_property_get(self, space, w_obj, w_cls=None):
         """property.__get__(obj[, type]) -> value
         Read the value of the property of the given obj."""

File pypy/module/__builtin__/descriptor.py

View file
  • Ignore whitespace
 from pypy.interpreter.baseobjspace import Wrappable
 from pypy.interpreter.error import OperationError
 from pypy.interpreter.function import StaticMethod, ClassMethod
-from pypy.interpreter.gateway import interp2app, unwrap_spec, W_Root
+from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.interpreter.typedef import (TypeDef, interp_attrproperty_w,
     generic_new_descr)
 from pypy.objspace.descroperation import object_getattribute
     def __init__(self, space):
         pass
 
-    @unwrap_spec(w_fget = (W_Root, 'space.w_None'),
-                 w_fset = (W_Root, 'space.w_None'),
-                 w_fdel = (W_Root, 'space.w_None'),
-                 w_doc = (W_Root, 'space.w_None'))
+    @unwrap_spec(w_fget = WrappedDefault(None),
+                 w_fset = WrappedDefault(None),
+                 w_fdel = WrappedDefault(None),
+                 w_doc = WrappedDefault(None))
     def init(self, space, w_fget=None, w_fset=None, w_fdel=None, w_doc=None):
         self.w_fget = w_fget
         self.w_fset = w_fset

File pypy/module/__builtin__/functional.py

View file
  • Ignore whitespace
 
 from pypy.interpreter.baseobjspace import Wrappable
 from pypy.interpreter.error import OperationError
-from pypy.interpreter.gateway import interp2app, unwrap_spec, W_Root
+from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.interpreter.typedef import TypeDef
 from pypy.rlib import jit
 from pypy.rlib.objectmodel import specialize
         n = 0
     return n
 
-@unwrap_spec(w_step = (W_Root, 'space.wrap(1)'))
+@unwrap_spec(w_step = WrappedDefault(1))
 def range_int(space, w_x, w_y=None, w_step=None):
     """Return a list of integers in arithmetic position from start (defaults
 to zero) to stop - 1 by step (defaults to 1).  Use a negative step to

File pypy/module/__builtin__/operation.py

View file
  • Ignore whitespace
 
 from pypy.interpreter import gateway
 from pypy.interpreter.error import OperationError
-from pypy.interpreter.gateway import unwrap_spec, W_Root
+from pypy.interpreter.gateway import unwrap_spec, WrappedDefault
 from pypy.rlib.runicode import UNICHR
 from pypy.rlib.rfloat import isnan, isinf, round_double
 from pypy.rlib import rfloat
 NDIGITS_MAX = int((rfloat.DBL_MANT_DIG - rfloat.DBL_MIN_EXP) * 0.30103)
 NDIGITS_MIN = -int((rfloat.DBL_MAX_EXP + 1) * 0.30103)
 
-@unwrap_spec(number=float, w_ndigits = (W_Root, 'space.wrap(0)'))
+@unwrap_spec(number=float, w_ndigits = WrappedDefault(0))
 def round(space, number, w_ndigits):
     """round(number[, ndigits]) -> floating point number
 
     """Return the integer ordinal of a character."""
     return space.ord(w_val)
 
-@unwrap_spec(w_modulus = (W_Root, 'space.w_None'))
+@unwrap_spec(w_modulus = WrappedDefault(None))
 def pow(space, w_base, w_exponent, w_modulus):
     """With two arguments, equivalent to ``base**exponent''.
 With three arguments, equivalent to ``(base**exponent) % modulus'',
 function).  Note that classes are callable."""
     return space.callable(w_object)
 
-@unwrap_spec(w_format_spec = (W_Root, 'space.wrap("")'))
+@unwrap_spec(w_format_spec = WrappedDefault(""))
 def format(space, w_obj, w_format_spec):
     """Format a obj according to format_spec"""
     return space.format(w_obj, w_format_spec)

File pypy/module/_cffi_backend/func.py

View file
  • Ignore whitespace
 from pypy.interpreter.error import OperationError, operationerrfmt
-from pypy.interpreter.gateway import unwrap_spec, W_Root
+from pypy.interpreter.gateway import unwrap_spec, WrappedDefault
 from pypy.module._cffi_backend import ctypeobj, cdataobj
 
 
 # ____________________________________________________________
 
-@unwrap_spec(ctype=ctypeobj.W_CType, w_init=(W_Root, 'space.w_None'))
+@unwrap_spec(ctype=ctypeobj.W_CType, w_init=WrappedDefault(None))
 def newp(space, ctype, w_init):
     return ctype.newp(w_init)
 

File pypy/module/_codecs/interp_codecs.py

View file
  • Ignore whitespace
 from pypy.interpreter.error import OperationError, operationerrfmt
-from pypy.interpreter.gateway import interp2app, unwrap_spec, W_Root
+from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.rlib.rstring import UnicodeBuilder
 from pypy.rlib.objectmodel import we_are_translated
 
     rname = "str_decode_%s" % (name.replace("_decode", ""), )
     assert hasattr(runicode, rname)
     @unwrap_spec(string='bufferstr', errors='str_or_None',
-                 w_final=(W_Root, 'space.w_False'))
+                 w_final=WrappedDefault(False))
     def wrap_decoder(space, string, errors="strict", w_final=None):
         if errors is None:
             errors = 'strict'
     return space.newtuple([space.wrap(result), space.wrap(len(uni))])
 
 @unwrap_spec(string='bufferstr', errors='str_or_None',
-             w_final = (W_Root, 'space.w_False'))
+             w_final = WrappedDefault(False))
 def utf_8_decode(space, string, errors="strict", w_final=None):
     if errors is None:
         errors = 'strict'
     return space.newtuple([space.wrap(result), space.wrap(consumed)])
 
 @unwrap_spec(data=str, errors='str_or_None', byteorder=int,
-             w_final=(W_Root, 'space.w_False'))
+             w_final=WrappedDefault(False))
 def utf_16_ex_decode(space, data, errors='strict', byteorder=0, w_final=None):
     if errors is None:
         errors = 'strict'
                            space.wrap(byteorder)])
 
 @unwrap_spec(data=str, errors='str_or_None', byteorder=int,
-             w_final=(W_Root, 'space.w_False'))
+             w_final=WrappedDefault(False))
 def utf_32_ex_decode(space, data, errors='strict', byteorder=0, w_final=None):
     final = space.is_true(w_final)
     state = space.fromcache(CodecState)
         return space.int_w(w_code)
 
 @unwrap_spec(string='bufferstr', errors='str_or_None',
-             w_final=(W_Root, 'space.w_False'))
+             w_final=WrappedDefault(False))
 def unicode_escape_decode(space, string, errors="strict", w_final=None):
     if errors is None:
         errors = 'strict'

File pypy/module/_continuation/interp_continuation.py

View file
  • Ignore whitespace
 from pypy.interpreter.executioncontext import ExecutionContext
 from pypy.interpreter.baseobjspace import Wrappable
 from pypy.interpreter.typedef import TypeDef
-from pypy.interpreter.gateway import interp2app, unwrap_spec, W_Root
+from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.interpreter.pycode import PyCode
 from pypy.interpreter.pyframe import PyFrame
 
         h = sthread.switch(global_state.destination.h)
         return post_switch(sthread, h)
 
-    @unwrap_spec(w_value = (W_Root, 'space.w_None'),
-                 w_to = (W_Root, 'space.w_None'))
+    @unwrap_spec(w_value = WrappedDefault(None),
+                 w_to = WrappedDefault(None))
     def descr_switch(self, w_value=None, w_to=None):
         global_state.w_value = w_value
         return self.switch(w_to)
 
-    @unwrap_spec(w_val = (W_Root, 'space.w_None'),
-                 w_tb = (W_Root, 'space.w_None'),
-                 w_to = (W_Root, 'space.w_None'))
+    @unwrap_spec(w_val = WrappedDefault(None),
+                 w_tb = WrappedDefault(None),
+                 w_to = WrappedDefault(None))
     def descr_throw(self, w_type, w_val=None, w_tb=None, w_to=None):
         from pypy.interpreter.pytraceback import check_traceback
         space = self.space

File pypy/module/_io/interp_bufferedio.py

View file
  • Ignore whitespace
 from __future__ import with_statement
 from pypy.interpreter.typedef import (
     TypeDef, GetSetProperty, generic_new_descr, interp_attrproperty_w)
-from pypy.interpreter.gateway import interp2app, unwrap_spec, W_Root
+from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.interpreter.buffer import RWBuffer
 from pypy.rlib.rstring import StringBuilder
         self._check_init(space)
         return space.call_method(self.w_raw, "fileno")
 
-    @unwrap_spec(w_size = (W_Root, 'space.w_None'))
+    @unwrap_spec(w_size = WrappedDefault(None))
     def truncate_w(self, space, w_size):
         self._check_init(space)
         with self.lock:

File pypy/module/_io/interp_stringio.py

View file
  • Ignore whitespace
 from pypy.interpreter.typedef import (
     TypeDef, generic_new_descr, GetSetProperty)
-from pypy.interpreter.gateway import interp2app, unwrap_spec, W_Root
+from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.module._io.interp_textio import W_TextIOBase, W_IncrementalNewlineDecoder
 from pypy.module._io.interp_iobase import convert_size
         self.buf = []
         self.pos = 0
 
-    @unwrap_spec(w_newline = (W_Root, 'space.wrap("\\n")'))
+    @unwrap_spec(w_newline = WrappedDefault("\n"))
     def descr_init(self, space, w_initvalue=None, w_newline=None):
         # In case __init__ is called multiple times
         self.buf = []

File pypy/module/_io/interp_textio.py

View file
  • Ignore whitespace
 from pypy.interpreter.typedef import (
     TypeDef, GetSetProperty, interp_attrproperty_w, interp_attrproperty,
     generic_new_descr)
-from pypy.interpreter.gateway import interp2app, unwrap_spec, W_Root
+from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.interpreter.baseobjspace import Wrappable
 from pypy.interpreter.error import OperationError
 from pypy.rlib.rarithmetic import intmask, r_ulonglong, r_uint
         self._writeflush(space)
         space.call_method(self.w_buffer, "flush")
 
-    @unwrap_spec(w_pos = (W_Root, 'space.w_None'))
+    @unwrap_spec(w_pos = WrappedDefault(None))
     def truncate_w(self, space, w_pos=None):
         self._check_init(space)
 

File pypy/module/_socket/interp_func.py

View file
  • Ignore whitespace
-from pypy.interpreter.gateway import unwrap_spec, W_Root
+from pypy.interpreter.gateway import unwrap_spec, WrappedDefault
 from pypy.module._socket.interp_socket import converted_error, W_RSocket
 from pypy.rlib import rsocket
 from pypy.rlib.rsocket import SocketError, INVALID_SOCKET
         raise converted_error(space, e)
     return common_wrapgethost(space, res)
 
-@unwrap_spec(name=str, w_proto = (W_Root, 'space.w_None'))
+@unwrap_spec(name=str, w_proto = WrappedDefault(None))
 def getservbyname(space, name, w_proto):
     """getservbyname(servicename[, protocolname]) -> integer
 
         raise converted_error(space, e)
     return space.wrap(port)
 
-@unwrap_spec(port=int, w_proto = (W_Root, 'space.w_None'))
+@unwrap_spec(port=int, w_proto = WrappedDefault(None))
 def getservbyport(space, port, w_proto):
     """getservbyport(port[, protocolname]) -> string
 

File pypy/module/_socket/interp_socket.py

View file
  • Ignore whitespace
 from pypy.interpreter.baseobjspace import Wrappable
 from pypy.interpreter.typedef import TypeDef, make_weakref_descr,\
      interp_attrproperty
-from pypy.interpreter.gateway import interp2app, unwrap_spec, W_Root
+from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.rlib.rarithmetic import intmask
 from pypy.rlib import rsocket
 from pypy.rlib.rsocket import RSocket, AF_INET, SOCK_STREAM
         except SocketError, e:
             raise converted_error(space, e)
 
-    @unwrap_spec(w_mode = (W_Root, 'space.wrap("r")'),
-                 w_buffsize = (W_Root, 'space.wrap(-1)'))
+    @unwrap_spec(w_mode = WrappedDefault("r"),
+                 w_buffsize = WrappedDefault(-1))
     def makefile_w(self, space, w_mode=None, w_buffsize=None):
         """makefile([mode[, buffersize]]) -> file object
 

File pypy/module/_sre/interp_sre.py

View file
  • Ignore whitespace
 from pypy.interpreter.typedef import GetSetProperty, TypeDef
 from pypy.interpreter.typedef import interp_attrproperty, interp_attrproperty_w
 from pypy.interpreter.typedef import make_weakref_descr
-from pypy.interpreter.gateway import interp2app, unwrap_spec, W_Root
+from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.interpreter.error import OperationError
 from pypy.rlib.rarithmetic import intmask
 from pypy.tool.pairtype import extendabletype
         return space.call_method(w_re, '_expand', space.wrap(self.srepat),
                                  space.wrap(self), w_template)
 
-    @unwrap_spec(w_groupnum = (W_Root, 'space.wrap(0)'))
+    @unwrap_spec(w_groupnum = WrappedDefault(0))
     def start_w(self, w_groupnum):
         return self.space.wrap(self.do_span(w_groupnum)[0])
 
-    @unwrap_spec(w_groupnum = (W_Root, 'space.wrap(0)'))
+    @unwrap_spec(w_groupnum = WrappedDefault(0))
     def end_w(self, w_groupnum):
         return self.space.wrap(self.do_span(w_groupnum)[1])
 
-    @unwrap_spec(w_groupnum = (W_Root, 'space.wrap(0)'))
+    @unwrap_spec(w_groupnum = WrappedDefault(0))
     def span_w(self, w_groupnum):
         start, end = self.do_span(w_groupnum)
         return self.space.newtuple([self.space.wrap(start),

File pypy/module/_warnings/interp_warnings.py

View file
  • Ignore whitespace
-from pypy.interpreter.gateway import unwrap_spec, W_Root
+from pypy.interpreter.gateway import unwrap_spec, WrappedDefault
 from pypy.interpreter.error import OperationError
 
 def create_filter(space, w_category, action):
     w_source_line = space.getitem(w_source_list, space.wrap(lineno - 1))
     return w_source_line
 
-@unwrap_spec(lineno=int, w_module = (W_Root, 'space.w_None'),
-             w_registry = (W_Root, 'space.w_None'),
-             w_module_globals = (W_Root, 'space.w_None'))
+@unwrap_spec(lineno=int, w_module = WrappedDefault(None),
+             w_registry = WrappedDefault(None),
+             w_module_globals = WrappedDefault(None))
 def warn_explicit(space, w_message, w_category, w_filename, lineno,
                   w_module=None, w_registry=None, w_module_globals=None):
 

File pypy/module/marshal/interp_marshal.py

View file
  • Ignore whitespace
 from pypy.interpreter.error import OperationError
-from pypy.interpreter.gateway import W_Root, unwrap_spec
+from pypy.interpreter.gateway import WrappedDefault, unwrap_spec
 from pypy.rlib.rarithmetic import intmask
 from pypy.rlib import rstackovf
 from pypy.module._file.interp_file import W_File
 
 Py_MARSHAL_VERSION = 2
 
-@unwrap_spec(w_version = (W_Root, 'space.wrap(%d)' % Py_MARSHAL_VERSION))
+@unwrap_spec(w_version = WrappedDefault(Py_MARSHAL_VERSION))
 def dump(space, w_data, w_f, w_version):
     """Write the 'data' object into the open file 'f'."""
     # special case real files for performance
     finally:
         writer.finished()
 
-@unwrap_spec(w_version = (W_Root, 'space.wrap(%d)' % Py_MARSHAL_VERSION))
+@unwrap_spec(w_version = WrappedDefault(Py_MARSHAL_VERSION))
 def dumps(space, w_data, w_version):
     """Return the string that would have been written to a file
 by dump(data, file)."""

File pypy/module/micronumpy/interp_numarray.py

View file
  • Ignore whitespace
 
 from pypy.interpreter.error import operationerrfmt, OperationError
 from pypy.interpreter.typedef import TypeDef, GetSetProperty
-from pypy.interpreter.gateway import interp2app, unwrap_spec, W_Root
+from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.module.micronumpy.base import W_NDimArray, convert_to_array,\
      ArrayArgumentException
 from pypy.module.micronumpy import interp_dtype, interp_ufuncs, interp_boxes
         return loop.multidim_dot(space, self, other,  result, dtype,
                                  other_critical_dim)
 
-    @unwrap_spec(w_axis = (W_Root, 'space.w_None'))
+    @unwrap_spec(w_axis = WrappedDefault(None))
     def descr_var(self, space, w_axis):
         return get_appbridge_cache(space).call_method(space, '_var', self,
                                                       w_axis)
 
-    @unwrap_spec(w_axis = (W_Root, 'space.w_None'))
+    @unwrap_spec(w_axis = WrappedDefault(None))
     def descr_std(self, space, w_axis):
         return get_appbridge_cache(space).call_method(space, '_std', self,
                                                       w_axis)

File pypy/module/micronumpy/interp_support.py

View file
  • Ignore whitespace
 from pypy.interpreter.error import OperationError, operationerrfmt
-from pypy.interpreter.gateway import unwrap_spec, is_none, W_Root
+from pypy.interpreter.gateway import unwrap_spec, is_none, WrappedDefault
 from pypy.rpython.lltypesystem import lltype, rffi
 from pypy.module.micronumpy import interp_dtype, loop
 from pypy.objspace.std.strutil import strip_spaces
     loop.fromstring_loop(a, dtype, itemsize, s)
     return space.wrap(a)
 
-@unwrap_spec(s=str, count=int, sep=str, w_dtype=(W_Root, 'space.w_None'))
+@unwrap_spec(s=str, count=int, sep=str, w_dtype=WrappedDefault(None))
 def fromstring(space, s, w_dtype=None, count=-1, sep=''):
     dtype = space.interp_w(interp_dtype.W_Dtype,
         space.call_function(space.gettypefor(interp_dtype.W_Dtype), w_dtype)

File pypy/module/select/interp_kqueue.py

View file
  • Ignore whitespace
 from pypy.interpreter.baseobjspace import Wrappable
 from pypy.interpreter.error import OperationError, operationerrfmt, exception_from_errno
-from pypy.interpreter.gateway import interp2app, unwrap_spec
+from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.interpreter.typedef import TypeDef, generic_new_descr, GetSetProperty
 from pypy.rlib._rsocket_rffi import socketclose
 from pypy.rlib.rarithmetic import r_uint
     def descr_close(self, space):
         self.close()
 
-    @unwrap_spec(max_events=int, w_timeout = (W_Root, 'space.w_None'))
+    @unwrap_spec(max_events=int, w_timeout = WrappedDefault(None))
     def descr_control(self, space, w_changelist, max_events, w_timeout):
 
         self.check_closed(space)

File pypy/module/select/interp_select.py

View file
  • Ignore whitespace
 from pypy.interpreter.typedef import TypeDef
 from pypy.interpreter.baseobjspace import Wrappable
-from pypy.interpreter.gateway import interp2app, unwrap_spec
+from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.interpreter.error import OperationError, wrap_oserror
 from pypy.rlib import rpoll
 import errno
             raise OperationError(space.w_KeyError,
                                  space.wrap(fd)) # XXX should this maybe be w_fd?
 
-    @unwrap_spec(w_timeout = (W_Root, 'space.w_None'))
+    @unwrap_spec(w_timeout = WrappedDefault(None))
     def poll(self, space, w_timeout):
         if space.is_w(w_timeout, space.w_None):
             timeout = -1
             reslist_w.append(list_w[i])
 
 
-@unwrap_spec(w_timeout = (W_Root, 'space.w_None'))
+@unwrap_spec(w_timeout = WrappedDefault(None))
 def select(space, w_iwtd, w_owtd, w_ewtd, w_timeout):
     """Wait until one or more file descriptors are ready for some kind of I/O.
 The first three arguments are sequences of file descriptors to be waited for:

File pypy/module/sys/vm.py

View file
  • Ignore whitespace
 
 from pypy.interpreter import gateway
 from pypy.interpreter.error import OperationError
-from pypy.interpreter.gateway import unwrap_spec, W_Root
+from pypy.interpreter.gateway import unwrap_spec, WrappedDefault
 from pypy.rlib import jit
 from pypy.rlib.runicode import MAXUNICODE
 
             "trying to change the builtin-in module %r" % (name,))
     space.setitem(w_modules, space.wrap(name), w_module)
 
-@unwrap_spec(w_depth = (W_Root, 'space.wrap(0)'))
+@unwrap_spec(w_depth = WrappedDefault(0))
 def _getframe(space, w_depth):
     """Return a frame object from the call stack.  If optional integer depth is
 given, return the frame object that many calls below the top of the stack.

File pypy/objspace/std/booltype.py

View file
  • Ignore whitespace
-from pypy.interpreter.gateway import interp2app, unwrap_spec, W_Root
+from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.objspace.std.stdtypedef import StdTypeDef
 from pypy.objspace.std.inttype import int_typedef
 
-@unwrap_spec(w_obj = (W_Root, 'space.w_False'))
+@unwrap_spec(w_obj = WrappedDefault(False))
 def descr__new__(space, w_booltype, w_obj):
     space.w_bool.check_user_subclass(w_booltype)
     if space.is_true(w_obj):

File pypy/objspace/std/complextype.py

View file
  • Ignore whitespace
-from pypy.interpreter.gateway import interp2app, unwrap_spec, W_Root
+from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.objspace.std.register_all import register_all
 from pypy.objspace.std.strutil import string_to_float, ParseStringError
     return realpart, imagpart
 
 
-@unwrap_spec(w_real = (W_Root, 'space.wrap("0.0")'))
+@unwrap_spec(w_real = WrappedDefault(0.0))
 def descr__new__(space, w_complextype, w_real, w_imag=None):
     from pypy.objspace.std.complexobject import W_ComplexObject
 

File pypy/objspace/std/floattype.py

View file
  • Ignore whitespace
 from pypy.rlib.unroll import unrolling_iterable
 from pypy.rlib import rfloat, rarithmetic
 from pypy.interpreter import typedef
-from pypy.interpreter.gateway import interp2app, unwrap_spec, W_Root
+from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.interpreter.baseobjspace import ObjSpace, W_Root
 from pypy.interpreter.error import OperationError
 from pypy.objspace.std.register_all import register_all
 register_all(vars(), globals())
 
 
-@unwrap_spec(w_x = (W_Root, 'space.wrap(0.0)'))
+@unwrap_spec(w_x = WrappedDefault(0.0))
 def descr__new__(space, w_floattype, w_x):
     from pypy.objspace.std.floatobject import W_FloatObject
     w_value = w_x     # 'x' is the keyword argument name in CPython

File pypy/objspace/std/inttype.py

View file
  • Ignore whitespace
 from pypy.interpreter import typedef
-from pypy.interpreter.gateway import interp2app, unwrap_spec, W_Root
+from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.interpreter.buffer import Buffer
 from pypy.objspace.std.register_all import register_all
     from pypy.objspace.std.longobject import newlong
     return newlong(space, bigint)
 
-@unwrap_spec(w_x = (W_Root, 'space.wrap(0)'))
+@unwrap_spec(w_x = WrappedDefault(0))
 def descr__new__(space, w_inttype, w_x, w_base=None):
     from pypy.objspace.std.intobject import W_IntObject
     w_longval = None

File pypy/objspace/std/longtype.py

View file
  • Ignore whitespace
 from pypy.interpreter.error import OperationError
 from pypy.interpreter import typedef
-from pypy.interpreter.gateway import interp2app, unwrap_spec, W_Root
+from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.objspace.std.register_all import register_all
 from pypy.objspace.std.stdtypedef import StdTypeDef, SMM
 from pypy.objspace.std.strutil import string_to_bigint, ParseStringError
     return space.long(w_int)
 
 
-@unwrap_spec(w_x = (W_Root, 'space.wrap(0)'))
+@unwrap_spec(w_x = WrappedDefault(0))
 def descr__new__(space, w_longtype, w_x, w_base=None):
     from pypy.objspace.std.longobject import W_LongObject
     from pypy.rlib.rbigint import rbigint

File pypy/objspace/std/stdtypedef.py

View file
  • Ignore whitespace
     unwrap_spec_kwds = {}
     for app_default in app_defaults:
         name = wrapper_signature[i]
-        unwrap_spec_kwds[name] = (gateway.W_Root,
-                                  'space.wrap(%r)' % (app_default,))
+        unwrap_spec_kwds[name] = gateway.WrappedDefault(app_default)
         i += 1
 
     wrapper_signature.insert(0, wrapper_signature.pop(selfindex))

File pypy/objspace/std/stringtype.py

View file
  • Ignore whitespace
-from pypy.interpreter.gateway import interp2app, unwrap_spec, W_Root
+from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.objspace.std.stdtypedef import StdTypeDef, SMM
 from pypy.objspace.std.basestringtype import basestring_typedef
 from pypy.objspace.std.register_all import register_all
 
 # ____________________________________________________________
 
-@unwrap_spec(w_object = (W_Root, 'space.wrap("")'))
+@unwrap_spec(w_object = WrappedDefault(""))
 def descr__new__(space, w_stringtype, w_object):
     # NB. the default value of w_object is really a *wrapped* empty string:
     #     there is gateway magic at work

File pypy/objspace/std/unicodetype.py

View file
  • Ignore whitespace
 from pypy.interpreter.error import OperationError, operationerrfmt
-from pypy.interpreter.gateway import interp2app, unwrap_spec, W_Root
+from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 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
                              w_encoding, w_errors)
 
 
-@unwrap_spec(w_string   = (W_Root, 'space.wrap("")'))
+@unwrap_spec(w_string = WrappedDefault(""))
 def descr_new_(space, w_unicodetype, w_string, w_encoding=None, w_errors=None):
     # NB. the default value of w_obj is really a *wrapped* empty string:
     #     there is gateway magic at work