Author: Maciej Fijalkowski <[email protected]>
Branch: kill-someobject
Changeset: r57979:bb4344e09c6e
Date: 2012-10-10 17:50 +0200
http://bitbucket.org/pypy/pypy/changeset/bb4344e09c6e/

Log:    finish module

diff --git a/pypy/module/__builtin__/compiling.py 
b/pypy/module/__builtin__/compiling.py
--- a/pypy/module/__builtin__/compiling.py
+++ b/pypy/module/__builtin__/compiling.py
@@ -84,17 +84,17 @@
         raise OperationError(space.w_TypeError,
               w('eval() arg 1 must be a string or code object'))
 
-    if space.is_w(w_globals, space.w_None):
+    if space.is_none(w_globals):
         caller = space.getexecutioncontext().gettopframe_nohidden()
         if caller is None:
             w_globals = space.newdict()
-            if space.is_w(w_locals, space.w_None):
+            if space.is_none(w_locals):
                 w_locals = w_globals
         else:
             w_globals = caller.w_globals
-            if space.is_w(w_locals, space.w_None):
+            if space.is_none(w_locals):
                 w_locals = caller.getdictscope()
-    elif space.is_w(w_locals, space.w_None):
+    elif space.is_none(w_locals):
         w_locals = w_globals
 
     # xxx removed: adding '__builtins__' to the w_globals dict, if there
diff --git a/pypy/module/__builtin__/descriptor.py 
b/pypy/module/__builtin__/descriptor.py
--- a/pypy/module/__builtin__/descriptor.py
+++ b/pypy/module/__builtin__/descriptor.py
@@ -1,7 +1,7 @@
 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
+from pypy.interpreter.gateway import interp2app, unwrap_spec, W_Root
 from pypy.interpreter.typedef import (TypeDef, interp_attrproperty_w,
     generic_new_descr)
 from pypy.objspace.descroperation import object_getattribute
@@ -48,7 +48,7 @@
                                    w(self), w(name))
 
 def descr_new_super(space, w_subtype, w_starttype, w_obj_or_type=None):
-    if space.is_w(w_obj_or_type, space.w_None):
+    if space.is_none(w_obj_or_type):
         w_type = None  # unbound super object
     else:
         w_objtype = space.type(w_obj_or_type)
@@ -96,6 +96,10 @@
     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'))
     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
diff --git a/pypy/module/__builtin__/functional.py 
b/pypy/module/__builtin__/functional.py
--- a/pypy/module/__builtin__/functional.py
+++ b/pypy/module/__builtin__/functional.py
@@ -47,7 +47,7 @@
         n = 0
     return n
 
-def range_int(space, w_x, w_y=NoneNotWrapped, w_step=1):
+def range_int(space, w_x, w_y=None, w_step=1):
     """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
 get a list in decending order."""
@@ -207,7 +207,7 @@
         self.w_iter = w_iter
         self.w_index = w_start
 
-    def descr___new__(space, w_subtype, w_iterable, w_start=NoneNotWrapped):
+    def descr___new__(space, w_subtype, w_iterable, w_start=None):
         self = space.allocate_instance(W_Enumerate, w_subtype)
         if w_start is None:
             w_start = space.wrap(0)
@@ -321,13 +321,13 @@
 
     def descr_new(space, w_subtype, w_start, w_stop=None, w_step=None):
         start = _toint(space, w_start)
-        if space.is_w(w_step, space.w_None):  # no step argument provided
+        if space.is_none(w_step):  # no step argument provided
             step = 1
             promote_step = True
         else:
             step  = _toint(space, w_step)
             promote_step = False
-        if space.is_w(w_stop, space.w_None):  # only 1 argument provided
+        if space.is_none(w_stop):  # only 1 argument provided
             start, stop = 0, start
         else:
             stop = _toint(space, w_stop)
diff --git a/pypy/module/__builtin__/interp_classobj.py 
b/pypy/module/__builtin__/interp_classobj.py
--- a/pypy/module/__builtin__/interp_classobj.py
+++ b/pypy/module/__builtin__/interp_classobj.py
@@ -311,7 +311,7 @@
             space.w_TypeError,
             space.wrap("instance() first arg must be class"))
     w_result = w_class.instantiate(space)
-    if not space.is_w(w_dict, space.w_None):
+    if not space.is_none(w_dict):
         w_result.setdict(space, w_dict)
     return w_result
 
@@ -656,7 +656,7 @@
 
 
     def descr_pow(self, space, w_other, w_modulo=None):
-        if space.is_w(w_modulo, space.w_None):
+        if space.is_none(w_modulo):
             w_a, w_b = _coerce_helper(space, self, w_other)
             if w_a is None:
                 w_a = self
@@ -676,7 +676,7 @@
             return space.w_NotImplemented
 
     def descr_rpow(self, space, w_other, w_modulo=None):
-        if space.is_w(w_modulo, space.w_None):
+        if space.is_none(w_modulo):
             w_a, w_b = _coerce_helper(space, self, w_other)
             if w_a is None:
                 w_a = self
diff --git a/pypy/module/__builtin__/operation.py 
b/pypy/module/__builtin__/operation.py
--- a/pypy/module/__builtin__/operation.py
+++ b/pypy/module/__builtin__/operation.py
@@ -4,7 +4,7 @@
 
 from pypy.interpreter import gateway
 from pypy.interpreter.error import OperationError
-from pypy.interpreter.gateway import unwrap_spec
+from pypy.interpreter.gateway import unwrap_spec, W_Root
 from pypy.rlib.runicode import UNICHR
 from pypy.rlib.rfloat import isnan, isinf, round_double
 from pypy.rlib import rfloat
@@ -59,7 +59,7 @@
     space.delattr(w_object, w_name)
     return space.w_None
 
-def getattr(space, w_object, w_name, w_defvalue=NoneNotWrapped):
+def getattr(space, w_object, w_name, w_defvalue=None):
     """Get a named attribute from an object.
 getattr(x, 'y') is equivalent to ``x.y''."""
     w_name = checkattrname(space, w_name)
@@ -176,7 +176,7 @@
 
 ''', filename=__file__).interphook("iter_sentinel")
 
-def iter(space, w_collection_or_callable, w_sentinel=NoneNotWrapped):
+def iter(space, w_collection_or_callable, w_sentinel=None):
     """iter(collection) -> iterator over the elements of the collection.
 
 iter(callable, sentinel) -> iterator calling callable() until it returns
@@ -187,7 +187,7 @@
     else:
         return iter_sentinel(space, w_collection_or_callable, w_sentinel)
 
-def next(space, w_iterator, w_default=NoneNotWrapped):
+def next(space, w_iterator, w_default=None):
     """next(iterator[, default])
 Return the next item from the iterator. If default is given and the iterator
 is exhausted, it is returned instead of raising StopIteration."""
@@ -202,7 +202,8 @@
     """Return the integer ordinal of a character."""
     return space.ord(w_val)
 
-def pow(space, w_base, w_exponent, w_modulus=None):
+@unwrap_spec(w_modulus = (W_Root, 'space.w_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'',
 but much more efficient for large exponents."""
diff --git a/pypy/module/_io/interp_textio.py b/pypy/module/_io/interp_textio.py
--- a/pypy/module/_io/interp_textio.py
+++ b/pypy/module/_io/interp_textio.py
@@ -2,7 +2,7 @@
 from pypy.interpreter.typedef import (
     TypeDef, GetSetProperty, interp_attrproperty_w, interp_attrproperty,
     generic_new_descr)
-from pypy.interpreter.gateway import interp2app, unwrap_spec
+from pypy.interpreter.gateway import interp2app, unwrap_spec, W_Root
 from pypy.interpreter.baseobjspace import Wrappable
 from pypy.interpreter.error import OperationError
 from pypy.rlib.rarithmetic import intmask, r_ulonglong, r_uint
@@ -46,13 +46,12 @@
     def descr_init(self, space, w_decoder, translate, w_errors=None):
         self.w_decoder = w_decoder
         self.translate = translate
-        if space.is_w(w_errors, space.w_None):
+        if space.is_none(w_errors):
             self.w_errors = space.wrap("strict")
         else:
             self.w_errors = w_errors
 
         self.seennl = 0
-        pendingcr = False
 
     def newlines_get_w(self, space):
         return self.w_newlines_dict.get(self.seennl, space.w_None)
@@ -365,11 +364,11 @@
             raise OperationError(space.w_IOError, space.wrap(
                 "could not determine default encoding"))
 
-        if space.is_w(w_errors, space.w_None):
+        if space.is_none(w_errors):
             w_errors = space.wrap("strict")
         self.w_errors = w_errors
 
-        if space.is_w(w_newline, space.w_None):
+        if space.is_none(w_newline):
             newline = None
         else:
             newline = space.unicode_w(w_newline)
@@ -484,6 +483,7 @@
         self._writeflush(space)
         space.call_method(self.w_buffer, "flush")
 
+    @unwrap_spec(w_pos = (W_Root, 'space.w_None'))
     def truncate_w(self, space, w_pos=None):
         self._check_init(space)
 
diff --git a/pypy/module/_minimal_curses/interp_curses.py 
b/pypy/module/_minimal_curses/interp_curses.py
--- a/pypy/module/_minimal_curses/interp_curses.py
+++ b/pypy/module/_minimal_curses/interp_curses.py
@@ -48,7 +48,7 @@
         fd = space.int_w(space.call_function(space.getattr(w_stdout,
                                              space.wrap('fileno'))))
     try:
-        if space.is_w(w_termname, space.w_None) or w_termname is None:
+        if space.is_none(w_termname):
             _curses_setupterm_null(fd)
         else:
             _curses_setupterm(space.str_w(w_termname), fd)
diff --git a/pypy/module/imp/interp_imp.py b/pypy/module/imp/interp_imp.py
--- a/pypy/module/imp/interp_imp.py
+++ b/pypy/module/imp/interp_imp.py
@@ -33,7 +33,7 @@
     return space.wrap(chr(a) + chr(b) + chr(c) + chr(d))
 
 def get_file(space, w_file, filename, filemode):
-    if w_file is None or space.is_w(w_file, space.w_None):
+    if space.is_none(w_file):
         try:
             return streamio.open_file_as_stream(filename, filemode)
         except StreamErrors, e:
@@ -46,7 +46,7 @@
 
 def find_module(space, w_name, w_path=None):
     name = space.str0_w(w_name)
-    if space.is_w(w_path, space.w_None):
+    if space.is_none(w_path):
         w_path = None
 
     find_info = importing.find_module(
@@ -103,7 +103,7 @@
     importing.load_source_module(
         space, w_modulename, w_mod,
         filename, stream.readall(), stream.try_to_find_file_descriptor())
-    if space.is_w(w_file, space.w_None):
+    if space.is_none(w_file):
         stream.close()
     return w_mod
 
@@ -118,7 +118,7 @@
     importing.load_compiled_module(
         space, w_modulename, w_module, filename, magic, timestamp,
         stream.readall())
-    if space.is_w(w_file, space.w_None):
+    if space.is_none(w_file):
         stream.close()
 
 @unwrap_spec(filename='str0')
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to