Commits

Maciej Fijalkowski committed 56e4185

try to use more consistently space.is_none

  • Participants
  • Parent commits d3d2090
  • Branches kill-someobject

Comments (0)

Files changed (30)

File pypy/interpreter/baseobjspace.py

         # done by a method call on w_two (and not on w_one, because of the
         # expected programming style where we say "if x is None" or
         # "if x is object").
+        assert w_two is not None
+        assert w_one is not None
         return w_two.is_w(self, w_one)
 
+    def is_none(self, w_obj):
+        """ mostly for checking inputargs that have unwrap_spec and
+        can accept both w_None and None
+        """
+        return w_obj is None or self.is_w(w_obj, self.w_None)
+
     def id(self, w_obj):
         w_result = w_obj.immutable_unique_id(self)
         if w_result is None:

File pypy/interpreter/gateway.py

         return name
 
 
-def is_none(space, w_obj):
-    return w_obj is None or space.is_w(w_obj, space.w_None)
-
 #________________________________________________________________
 
 

File pypy/module/__pypy__/interp_identitydict.py

             raise OperationError(space.w_KeyError, w_key)
 
     def get(self, space, w_key, w_default=None):
+        if w_default is None:
+            w_default = space.w_None
         return self.dict.get(w_key, w_default)
 
     def keys(self, space):

File pypy/module/_cffi_backend/ccallback.py

                                   "expected a callable object, not %s",
                                   space.type(w_callable).getname(space))
         self.w_callable = w_callable
-        self.w_error = w_error
         #
         fresult = self.getfunctype().ctitem
         size = fresult.size
                 size = SIZE_OF_FFI_ARG
             self.ll_error = lltype.malloc(rffi.CCHARP.TO, size, flavor='raw',
                                           zero=True)
-        if not space.is_w(w_error, space.w_None):
+        if not space.is_none(w_error):
             convert_from_object_fficallback(fresult, self.ll_error, w_error)
         #
         self.unique_id = compute_unique_id(self)

File pypy/module/_cffi_backend/func.py

 from pypy.interpreter.error import OperationError, operationerrfmt
-from pypy.interpreter.baseobjspace import Wrappable
-from pypy.interpreter.gateway import interp2app, unwrap_spec
-from pypy.rpython.lltypesystem import lltype, rffi
-
+from pypy.interpreter.gateway import unwrap_spec, W_Root
 from pypy.module._cffi_backend import ctypeobj, cdataobj
 
 
 # ____________________________________________________________
 
-@unwrap_spec(ctype=ctypeobj.W_CType)
-def newp(space, ctype, w_init=None):
+@unwrap_spec(ctype=ctypeobj.W_CType, w_init=(W_Root, 'space.w_None'))
+def newp(space, ctype, w_init):
     return ctype.newp(w_init)
 
 # ____________________________________________________________

File pypy/module/_codecs/interp_codecs.py

 
 
 @unwrap_spec(errors=str)
-def encode(space, w_obj, w_encoding=NoneNotWrapped, errors='strict'):
+def encode(space, w_obj, w_encoding=None, errors='strict'):
     """encode(obj, [encoding[,errors]]) -> object
 
     Encodes obj using the codec registered for encoding. encoding defaults
     return space.newtuple([space.wrap(s), space.wrap(len(s))])
 
 @unwrap_spec(errors=str)
-def decode(space, w_obj, w_encoding=NoneNotWrapped, errors='strict'):
+def decode(space, w_obj, w_encoding=None, errors='strict'):
     """decode(obj, [encoding[,errors]]) -> object
 
     Decodes obj using the codec registered for encoding. encoding defaults
         raise OperationError(space.w_TypeError, space.wrap("invalid mapping"))
 
 
-@unwrap_spec(string=str, errors='str_or_None',
-             w_mapping = (W_Root, 'space.w_None'))
+@unwrap_spec(string=str, errors='str_or_None')
 def charmap_decode(space, string, errors="strict", w_mapping=None):
     if errors is None:
         errors = 'strict'
     if len(string) == 0:
         return space.newtuple([space.wrap(u''), space.wrap(0)])
 
-    if space.is_w(w_mapping, space.w_None):
+    if space.is_none(w_mapping):
         mapping = None
     else:
         mapping = Charmap_Decode(space, w_mapping)
         final, state.decode_error_handler, mapping)
     return space.newtuple([space.wrap(result), space.wrap(consumed)])
 
-@unwrap_spec(uni=unicode, errors='str_or_None',
-             w_mapping = (W_Root, 'space.w_None'))
+@unwrap_spec(uni=unicode, errors='str_or_None')
 def charmap_encode(space, uni, errors="strict", w_mapping=None):
     if errors is None:
         errors = 'strict'
-    if space.is_w(w_mapping, space.w_None):
+    if space.is_none(w_mapping):
         mapping = None
     else:
         mapping = Charmap_Encode(space, w_mapping)

File pypy/module/_ffi/interp_struct.py

 @unwrap_spec(name=str)
 def descr_new_structdescr(space, w_type, name, w_fields=None):
     descr = W__StructDescr(name)
-    if w_fields is not space.w_None:
+    if not space.is_none(w_fields):
         descr.define_fields(space, w_fields)
     return descr
 

File pypy/module/_file/interp_file.py

     def direct_truncate(self, w_size=None):  # note: a wrapped size!
         stream = self.getstream()
         space = self.space
-        if w_size is None or space.is_w(w_size, space.w_None):
+        if space.is_none(w_size):
             size = stream.tell()
         else:
             size = space.r_longlong_w(w_size)

File pypy/module/_io/interp_bufferedio.py

 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
+from pypy.interpreter.gateway import interp2app, unwrap_spec, W_Root
 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")
 
-    def truncate_w(self, space, w_size=None):
+    @unwrap_spec(w_size = (W_Root, 'space.w_None'))
+    def truncate_w(self, space, w_size):
         self._check_init(space)
         with self.lock:
             if self.writable:

File pypy/module/_io/interp_bytesio.py

         self.string_size = 0
         self.pos = 0
 
-        if not space.is_w(w_initial_bytes, space.w_None):
+        if not space.is_none(w_initial_bytes):
             self.write_w(space, w_initial_bytes)
             self.pos = 0
 
     def truncate_w(self, space, w_size=None):
         self._check_closed(space)
 
-        if space.is_w(w_size, space.w_None):
+        if space.is_none(w_size):
             size = self.pos
         else:
             size = space.r_longlong_w(w_size)

File pypy/module/_io/interp_fileio.py

     def truncate_w(self, space, w_size=None):
         self._check_closed(space)
         self._check_writable(space)
-        if space.is_w(w_size, space.w_None):
+        if space.is_none(w_size):
             w_size = self.tell_w(space)
 
         try:

File pypy/module/_io/interp_iobase.py

 DEFAULT_BUFFER_SIZE = 8192
 
 def convert_size(space, w_size):
-    if space.is_w(w_size, space.w_None):
+    if space.is_none(w_size):
         return -1
     else:
         return space.int_w(w_size)

File pypy/module/_io/interp_stringio.py

 from pypy.interpreter.typedef import (
     TypeDef, generic_new_descr, GetSetProperty)
-from pypy.interpreter.gateway import interp2app, unwrap_spec
+from pypy.interpreter.gateway import interp2app, unwrap_spec, W_Root
 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
 
-    def descr_init(self, space, w_initvalue=None, w_newline="\n"):
+    @unwrap_spec(w_newline = (W_Root, 'space.wrap("\\n")'))
+    def descr_init(self, space, w_initvalue=None, w_newline=None):
         # In case __init__ is called multiple times
         self.buf = []
         self.pos = 0
                 space.wrap(int(self.readtranslate))
             )
 
-        if not space.is_w(w_initvalue, space.w_None):
+        if not space.is_none(w_initvalue):
             self.write_w(space, w_initvalue)
             self.pos = 0
 
 
     def truncate_w(self, space, w_size=None):
         self._check_closed(space)
-        if space.is_w(w_size, space.w_None):
+        if space.is_none(w_size):
             size = self.pos
         else:
             size = space.int_w(w_size)

File pypy/module/_locale/interp_locale.py

 def setlocale(space, category, w_locale=None):
     "(integer,string=None) -> string. Activates/queries locale processing."
 
-    if w_locale is None or space.is_w(w_locale, space.w_None):
+    if space.is_none(w_locale):
         locale = None
     else:
         locale = space.str_w(w_locale)

File pypy/module/_multiprocessing/interp_semaphore.py

     def semlock_acquire(self, space, block, w_timeout):
         if not block:
             full_msecs = 0
-        elif space.is_w(w_timeout, space.w_None):
+        elif space.is_none(w_timeout):
             full_msecs = rwin32.INFINITE
         else:
             timeout = space.float_w(w_timeout)

File pypy/module/_rawffi/array.py

 to app-level with apropriate interface
 """
 
-from pypy.interpreter.gateway import interp2app, unwrap_spec, is_none
+from pypy.interpreter.gateway import interp2app, unwrap_spec
 from pypy.interpreter.typedef import TypeDef, GetSetProperty, interp_attrproperty
 from pypy.rpython.lltypesystem import lltype, rffi
 from pypy.interpreter.error import OperationError
 from pypy.module._rawffi.interp_rawffi import TYPEMAP
 from pypy.module._rawffi.interp_rawffi import size_alignment
 from pypy.module._rawffi.interp_rawffi import unpack_shape_with_length
-from pypy.rlib.rarithmetic import intmask, r_uint
+from pypy.rlib.rarithmetic import r_uint
 
 def push_elem(ll_array, pos, value):
     TP = lltype.typeOf(value)
     @unwrap_spec(length=int, autofree=bool)
     def descr_call(self, space, length, w_items=None, autofree=False):
         result = self.allocate(space, length, autofree)
-        if is_none(space, w_items):
+        if not space.is_none(w_items):
             items_w = space.unpackiterable(w_items)
             iterlength = len(items_w)
             if iterlength > length:

File pypy/module/_ssl/interp_ssl.py

 
     sock_fd = space.int_w(space.call_method(w_sock, "fileno"))
     w_timeout = space.call_method(w_sock, "gettimeout")
-    if space.is_w(w_timeout, space.w_None):
+    if space.is_none(w_timeout):
         has_timeout = False
     else:
         has_timeout = True
-    if space.is_w(w_key_file, space.w_None):
+    if space.is_none(w_key_file):
         key_file = None
     else:
         key_file = space.str_w(w_key_file)
-    if space.is_w(w_cert_file, space.w_None):
+    if space.is_none(w_cert_file):
         cert_file = None
     else:
         cert_file = space.str_w(w_cert_file)
-    if space.is_w(w_cacerts_file, space.w_None):
+    if space.is_none(w_cacerts_file):
         cacerts_file = None
     else:
         cacerts_file = space.str_w(w_cacerts_file)
-    if space.is_w(w_ciphers, space.w_None):
+    if space.is_none(w_ciphers):
         ciphers = None
     else:
         ciphers = space.str_w(w_ciphers)

File pypy/module/_warnings/interp_warnings.py

 
 
 def get_source_line(space, w_globals, lineno):
-    if space.is_w(w_globals, space.w_None):
+    if space.is_none(w_globals):
         return None
 
     # Check/get the requisite pieces needed for the loader.

File pypy/module/_weakref/interp__weakref.py

     if __args__.arguments_w:
         raise OperationError(space.w_TypeError, space.wrap(
             "__new__ expected at most 2 arguments"))
-    if space.is_w(w_callable, space.w_None):
+    if space.is_none(w_callable):
         return get_or_make_weakref(space, w_subtype, w_obj)
     else:
         return make_weakref_with_callback(space, w_subtype, w_obj, w_callable)
     """Create a proxy object that weakly references 'obj'.
 'callback', if given, is called with the proxy as an argument when 'obj'
 is about to be finalized."""
-    if space.is_w(w_callable, space.w_None):
+    if space.is_none(w_callable):
         return get_or_make_proxy(space, w_obj)
     else:
         return make_proxy_with_callback(space, w_obj, w_callable)

File pypy/module/cStringIO/interp_stringio.py

         self.seek(i)
         return ''.join(bigbuffer[p:i])
 
-    def descr_truncate(self, w_size=None):  # note: a wrapped size!
+    def descr_truncate(self, w_size=None):
         self.check_closed()
         space = self.space
-        if w_size is None or space.is_w(w_size, space.w_None):
+        if space.is_none(w_size):
             size = self.tell()
         else:
             size = space.int_w(w_size)
 # ____________________________________________________________
 
 def StringIO(space, w_string=None):
-    if space.is_w(w_string, space.w_None):
+    if space.is_none(w_string):
         return space.wrap(W_OutputType(space))
     else:
         string = space.bufferstr_w(w_string)

File pypy/module/cpyext/methodobject.py

     return ret
 
 def cmethod_descr_get(space, w_function, w_obj, w_cls=None):
-    asking_for_bound = (space.is_w(w_cls, space.w_None) or
+    asking_for_bound = (space.is_none(w_cls) or
                         not space.is_w(w_obj, space.w_None) or
                         space.is_w(w_cls, space.type(space.w_None)))
     if asking_for_bound:

File pypy/module/itertools/interp_itertools.py

     def __init__(self, space, w_iterable, w_fun):
         self.space = space
         self.w_iterable = self.space.iter(w_iterable)
-        self.identity_fun = self.space.is_w(w_fun, self.space.w_None)
-        self.w_fun = w_fun
+        if space.is_none(w_fun):
+            self.w_fun = None
+        else:
+            self.w_fun = w_fun
         self.index = 0
         self.lookahead = False
         self.exhausted = False
                 raise
             else:
                 self.w_lookahead = w_obj
-                if self.identity_fun:
+                if self.w_fun is None:
                     self.w_key = w_obj
                 else:
                     self.w_key = self.space.call_function(self.w_fun, w_obj)
                 else:
                     raise
             else:
-                if self.identity_fun:
+                if self.w_fun is None:
                     w_new_key = w_obj
                 else:
                     w_new_key = self.space.call_function(self.w_fun, w_obj)
                     self.new_group = True #new group
                     raise StopIteration
 
-@unwrap_spec(w_key = (W_Root, 'space.w_None'))
-def W_GroupBy___new__(space, w_subtype, w_iterable, w_key):
+def W_GroupBy___new__(space, w_subtype, w_iterable, w_key=None):
     r = space.allocate_instance(W_GroupBy, w_subtype)
     r.__init__(space, w_iterable, w_key)
     return space.wrap(r)
         self.stopped = True
         return w_result
 
-@unwrap_spec(w_r = (W_Root, 'space.w_None'))
-def W_Permutations__new__(space, w_subtype, w_iterable, w_r):
+def W_Permutations__new__(space, w_subtype, w_iterable, w_r=None):
     pool_w = space.fixedview(w_iterable)
-    if space.is_w(w_r, space.w_None):
+    if space.is_none(w_r):
         r = len(pool_w)
     else:
         r = space.gateway_nonnegint_w(w_r)

File pypy/module/micronumpy/interp_arrayops.py

 from pypy.module.micronumpy.iter import Chunk, Chunks
 from pypy.module.micronumpy.strides import shape_agreement
 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
 
-@unwrap_spec(w_x = (W_Root, 'space.w_None'), w_y = (W_Root, 'space.w_None'))
-def where(space, w_arr, w_x, w_y):
+def where(space, w_arr, w_x=None, w_y=None):
     """where(condition, [x, y])
 
     Return elements, either from `x` or `y`, depending on `condition`.
     
     NOTE: support for not passing x and y is unsupported
     """
-    if space.is_w(w_y, space.w_None):
-        if space.is_w(w_x, space.w_None):
+    if space.is_none(w_y):
+        if space.is_none(w_x):
             raise OperationError(space.w_NotImplementedError, space.wrap(
                 "1-arg where unsupported right now"))
         raise OperationError(space.w_ValueError, space.wrap(
             "Where should be called with either 1 or 3 arguments"))
+    if space.is_none(w_x):
+        raise OperationError(space.w_ValueError, space.wrap(
+            "Where should be called with either 1 or 3 arguments"))
     arr = convert_to_array(space, w_arr)
     x = convert_to_array(space, w_x)
     y = convert_to_array(space, w_y)
 @unwrap_spec(repeats=int)
 def repeat(space, w_arr, repeats, w_axis=None):
     arr = convert_to_array(space, w_arr)
-    if is_none(space, w_axis):
+    if space.is_none(w_axis):
         arr = arr.descr_flatten(space)
         orig_size = arr.get_shape()[0]
         shape = [arr.get_shape()[0] * repeats]

File pypy/module/micronumpy/interp_numarray.py

 
 from pypy.interpreter.error import operationerrfmt, OperationError
 from pypy.interpreter.typedef import TypeDef, GetSetProperty
-from pypy.interpreter.gateway import interp2app, unwrap_spec, is_none,\
-     W_Root
+from pypy.interpreter.gateway import interp2app, unwrap_spec, W_Root
 from pypy.module.micronumpy.base import W_NDimArray, convert_to_array,\
      ArrayArgumentException
 from pypy.module.micronumpy import interp_dtype, interp_ufuncs, interp_boxes
 from pypy.rlib.rstring import StringBuilder
 
 def _find_shape(space, w_size):
-    if is_none(space, w_size):
+    if space.is_none(w_size):
         return []
     if space.isinstance_w(w_size, space.w_int):
         return [space.int_w(w_size)]
         return space.newlist(l_w)
 
     def descr_ravel(self, space, w_order=None):
-        if is_none(space, w_order):
+        if space.is_none(w_order):
             order = 'C'
         else:
             order = space.str_w(w_order)
         # if w_axis is None and w_out is Nont this is an equivalent to
         # fancy indexing
         raise Exception("unsupported for now")
-        if not is_none(space, w_axis):
+        if not space.is_none(w_axis):
             raise OperationError(space.w_NotImplementedError,
                                  space.wrap("axis unsupported for take"))
-        if not is_none(space, w_out):
+        if not space.is_none(w_out):
             raise OperationError(space.w_NotImplementedError,
                                  space.wrap("out unsupported for take"))
         return self.getitem_int(space, convert_to_array(space, w_obj))
 
     def descr_compress(self, space, w_obj, w_axis=None):
-        if not is_none(space, w_axis):
+        if not space.is_none(w_axis):
             raise OperationError(space.w_NotImplementedError,
                                  space.wrap("axis unsupported for compress"))
         index = convert_to_array(space, w_obj)
         return coords
 
     def descr_item(self, space, w_arg=None):
-        if is_none(space, w_arg):
+        if space.is_none(w_arg):
             if self.is_scalar():
                 return self.get_scalar_value().item(space)
             if self.get_size() == 1:
 
     def _reduce_ufunc_impl(ufunc_name, promote_to_largest=False):
         def impl(self, space, w_axis=None, w_out=None, w_dtype=None):
-            if is_none(space, w_out):
+            if space.is_none(w_out):
                 out = None
             elif not isinstance(w_out, W_NDimArray):
                 raise OperationError(space.w_TypeError, space.wrap( 
     descr_any = _reduce_ufunc_impl('logical_or')
 
     def descr_mean(self, space, w_axis=None, w_out=None):
-        if is_none(space, w_axis):
+        if space.is_none(w_axis):
             w_denom = space.wrap(self.get_size())
         else:
             axis = unwrap_axis_arg(space, len(self.get_shape()), w_axis)
 @unwrap_spec(offset=int)
 def descr_new_array(space, w_subtype, w_shape, w_dtype=None, w_buffer=None,
                     offset=0, w_strides=None, w_order=None):
-    if (offset != 0 or is_none(space, w_strides) or
-        not is_none(space, w_order) or
-        not is_none(space, w_buffer)):
+    if (offset != 0 or space.is_none(w_strides) or not space.is_none(w_order) or
+        not space.is_none(w_buffer)):
         raise OperationError(space.w_NotImplementedError,
                              space.wrap("unsupported param"))
     dtype = space.interp_w(interp_dtype.W_Dtype,
 def array(space, w_object, w_dtype=None, copy=True, w_order=None, subok=False,
           ndmin=0):
     if not space.issequence_w(w_object):
-        if is_none(space, w_dtype):
+        if space.is_none(w_dtype):
             w_dtype = interp_ufuncs.find_dtype_for_scalar(space, w_object)
         dtype = space.interp_w(interp_dtype.W_Dtype,
           space.call_function(space.gettypefor(interp_dtype.W_Dtype), w_dtype))
         return W_NDimArray.new_scalar(space, dtype, w_object)
-    if is_none(space, w_order):
+    if space.is_none(w_order):
         order = 'C'
     else:
         order = space.str_w(w_order)

File pypy/module/micronumpy/interp_ufuncs.py

 from pypy.interpreter.baseobjspace import Wrappable
 from pypy.interpreter.error import OperationError, operationerrfmt
-from pypy.interpreter.gateway import interp2app, unwrap_spec,\
-     is_none
+from pypy.interpreter.gateway import interp2app, unwrap_spec
 from pypy.interpreter.typedef import TypeDef, GetSetProperty, interp_attrproperty
 from pypy.module.micronumpy import interp_boxes, interp_dtype, loop
 from pypy.rlib import jit
         from pypy.module.micronumpy.interp_numarray import W_NDimArray
         if w_axis is None:
             w_axis = space.wrap(0)
-        if is_none(space, w_out):
+        if space.is_none(w_out):
             out = None
         elif not isinstance(w_out, W_NDimArray):
             raise OperationError(space.w_TypeError, space.wrap(
             promote_bools=self.promote_bools,
             allow_complex=self.allow_complex,
             )
-        if is_none(space, w_out):
+        if space.is_none(w_out):
             out = None
         elif not isinstance(w_out, W_NDimArray):
             raise OperationError(space.w_TypeError, space.wrap(

File pypy/module/oracle/interp_cursor.py

     @unwrap_spec(name=str)
     def callfunc(self, space, name, w_returnType, w_parameters=None):
         retvar = interp_variable.newVariableByType(space, self, w_returnType, 1)
-        if space.is_w(w_parameters, space.w_None):
+        if space.is_none(w_parameters):
             w_parameters = None
 
         self._call(space, name, retvar, w_parameters)
 
     @unwrap_spec(name=str)
     def callproc(self, space, name, w_parameters=None):
-        if space.is_w(w_parameters, space.w_None):
+        if space.is_none(w_parameters):
             w_parameters = None
 
         self._call(space, name, None, w_parameters)
 
         return space.w_None
 
-    def fetchmany(self, space, w_numRows=NoneNotWrapped):
+    def fetchmany(self, space, w_numRows=None):
         if w_numRows is not None:
             numRows = space.int_w(w_numRows)
         else:
     @unwrap_spec(size=int)
     def var(self, space, w_type, size=0, w_arraysize=None,
             w_inconverter=None, w_outconverter=None):
-        if space.is_w(w_arraysize, space.w_None):
+        if space.is_none(w_arraysize):
             arraySize = self.bindArraySize
         else:
             arraySize = space.int_w(w_arraysize)

File pypy/module/pyexpat/interp_pyexpat.py

 from pypy.interpreter.baseobjspace import Wrappable
 from pypy.interpreter.typedef import TypeDef, GetSetProperty
-from pypy.interpreter.gateway import NoneNotWrapped
-from pypy.interpreter.gateway import interp2app, unwrap_spec
+from pypy.interpreter.gateway import interp2app, unwrap_spec, W_Root
 from pypy.interpreter.error import OperationError
 from pypy.rlib import rgc
 from pypy.rpython.lltypesystem import rffi, lltype
         else:
             context = space.str_w(w_context)
 
-        if space.is_w(w_encoding, space.w_None):
+        if space.is_none(w_encoding):
             encoding = None
         else:
             encoding = space.str_w(w_encoding)
     )
 
 def ParserCreate(space, w_encoding=None, w_namespace_separator=None,
-                 w_intern=NoneNotWrapped):
+                 w_intern=None):
     """ParserCreate([encoding[, namespace_separator]]) -> parser
 Return a new XML parser object."""
-    if space.is_w(w_encoding, space.w_None):
+    if space.is_none(w_encoding):
         encoding = None
     elif space.is_true(space.isinstance(w_encoding, space.w_str)):
         encoding = space.str_w(w_encoding)
             space.wrap('ParserCreate() argument 1 must be string or None,'
                        ' not %s' % (type_name,)))
 
-    if space.is_w(w_namespace_separator, space.w_None):
+    if space.is_none(w_namespace_separator):
         namespace_separator = 0
     elif space.is_true(space.isinstance(w_namespace_separator, space.w_str)):
         separator = space.str_w(w_namespace_separator)

File pypy/module/rctime/interp_time.py

 def _get_inttime(space, w_seconds):
     # w_seconds can be a wrapped None (it will be automatically wrapped
     # in the callers, so we never get a real None here).
-    if space.is_w(w_seconds, space.w_None):
+    if space.is_none(w_seconds):
         seconds = pytime.time()
     else:
         seconds = space.float_w(w_seconds)
     return space.call_function(w_struct_time, w_time_tuple)
 
 def _gettmarg(space, w_tup, allowNone=True):
-    if allowNone and space.is_w(w_tup, space.w_None):
+    if space.is_none(w_tup):
+        if not allowNone:
+            raise OperationError(space.w_TypeError,
+                                 space.wrap("tuple expected"))
         # default to the current local time
         tt = rffi.r_time_t(int(pytime.time()))
         t_ref = lltype.malloc(rffi.TIME_TP.TO, 1, flavor='raw')

File pypy/objspace/std/typetype.py

 from pypy.objspace.std.stdtypedef import StdTypeDef
 
 
-def descr__new__(space, w_typetype, w_name, w_bases=gateway.NoneNotWrapped,
-    w_dict=gateway.NoneNotWrapped):
+def descr__new__(space, w_typetype, w_name, w_bases=None, w_dict=None):
 
     "This is used to create user-defined classes only."
     # XXX check types

File pypy/objspace/std/unicodetype.py

     return space.sys.defaultencoding
 
 def _get_encoding_and_errors(space, w_encoding, w_errors):
-    if space.is_w(w_encoding, space.w_None):
+    if space.is_none(w_encoding):
         encoding = None
     else:
         encoding = space.str_w(w_encoding)
-    if space.is_w(w_errors, space.w_None):
+    if space.is_none(w_errors):
         errors = None
     else:
         errors = space.str_w(w_errors)
                              w_encoding, w_errors)
 
 
-@unwrap_spec(w_string   = (W_Root, 'space.wrap("")'),
-             w_encoding = (W_Root, 'space.w_None'),
-             w_errors   = (W_Root, 'space.w_None'))
-def descr_new_(space, w_unicodetype, w_string, w_encoding, w_errors):
+@unwrap_spec(w_string   = (W_Root, 'space.wrap("")'))
+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
     from pypy.objspace.std.unicodeobject import W_UnicodeObject