[pypy-commit] pypy default: Remove from stubs.py functions that are already implemented

amauryfa noreply at buildbot.pypy.org
Sat Aug 20 17:00:30 CEST 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: 
Changeset: r46667:7208c6812199
Date: 2011-08-20 14:51 +0200
http://bitbucket.org/pypy/pypy/changeset/7208c6812199/

Log:	Remove from stubs.py functions that are already implemented

diff --git a/pypy/module/cpyext/setobject.py b/pypy/module/cpyext/setobject.py
--- a/pypy/module/cpyext/setobject.py
+++ b/pypy/module/cpyext/setobject.py
@@ -14,6 +14,11 @@
 
 @cpython_api([PyObject], PyObject)
 def PySet_New(space, w_iterable):
+    """Return a new set containing objects returned by the iterable.  The
+    iterable may be NULL to create a new empty set.  Return the new set on
+    success or NULL on failure.  Raise TypeError if iterable is not
+    actually iterable.  The constructor is also useful for copying a set
+    (c=set(s))."""
     if w_iterable is None:
         return space.call_function(space.w_set)
     else:
@@ -21,6 +26,15 @@
 
 @cpython_api([PyObject, PyObject], rffi.INT_real, error=-1)
 def PySet_Add(space, w_s, w_obj):
+    """Add key to a set instance.  Does not apply to frozenset
+    instances.  Return 0 on success or -1 on failure. Raise a TypeError if
+    the key is unhashable. Raise a MemoryError if there is no room to grow.
+    Raise a SystemError if set is an not an instance of set or its
+    subtype.
+
+    Now works with instances of frozenset or its subtypes.
+    Like PyTuple_SetItem() in that it can be used to fill-in the
+    values of brand new frozensets before they are exposed to other code."""
     if not PySet_Check(space, w_s):
         PyErr_BadInternalCall(space)
     space.call_method(w_s, 'add', w_obj)
@@ -28,6 +42,12 @@
 
 @cpython_api([PyObject, PyObject], rffi.INT_real, error=-1)
 def PySet_Discard(space, w_s, w_obj):
+    """Return 1 if found and removed, 0 if not found (no action taken), and -1 if an
+    error is encountered.  Does not raise KeyError for missing keys.  Raise a
+    TypeError if the key is unhashable.  Unlike the Python discard()
+    method, this function does not automatically convert unhashable sets into
+    temporary frozensets. Raise PyExc_SystemError if set is an not an
+    instance of set or its subtype."""
     if not PySet_Check(space, w_s):
         PyErr_BadInternalCall(space)
     space.call_method(w_s, 'discard', w_obj)
@@ -36,10 +56,14 @@
 
 @cpython_api([PyObject], Py_ssize_t, error=CANNOT_FAIL)
 def PySet_GET_SIZE(space, w_s):
+    """Macro form of PySet_Size() without error checking."""
     return space.int_w(space.len(w_s))
 
 @cpython_api([PyObject], Py_ssize_t, error=-1)
 def PySet_Size(space, ref):
+    """Return the length of a set or frozenset object. Equivalent to
+    len(anyset).  Raises a PyExc_SystemError if anyset is not a set, frozenset,
+    or an instance of a subtype."""
     if not PySet_Check(space, ref):
         raise OperationError(space.w_TypeError,
                              space.wrap("expected set object"))
diff --git a/pypy/module/cpyext/stubs.py b/pypy/module/cpyext/stubs.py
--- a/pypy/module/cpyext/stubs.py
+++ b/pypy/module/cpyext/stubs.py
@@ -1927,12 +1927,6 @@
     raise NotImplementedError
 
 @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
-def PySet_Check(space, p):
-    """Return true if p is a set object or an instance of a subtype.
-    """
-    raise NotImplementedError
-
- at cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
 def PyFrozenSet_Check(space, p):
     """Return true if p is a frozenset object or an instance of a
     subtype.
@@ -1958,15 +1952,6 @@
     raise NotImplementedError
 
 @cpython_api([PyObject], PyObject)
-def PySet_New(space, iterable):
-    """Return a new set containing objects returned by the iterable.  The
-    iterable may be NULL to create a new empty set.  Return the new set on
-    success or NULL on failure.  Raise TypeError if iterable is not
-    actually iterable.  The constructor is also useful for copying a set
-    (c=set(s))."""
-    raise NotImplementedError
-
- at cpython_api([PyObject], PyObject)
 def PyFrozenSet_New(space, iterable):
     """Return a new frozenset containing objects returned by the iterable.
     The iterable may be NULL to create a new empty frozenset.  Return the new
@@ -1978,44 +1963,6 @@
     building-up new frozensets with PySet_Add()."""
     raise NotImplementedError
 
- at cpython_api([PyObject], Py_ssize_t, error=-1)
-def PySet_Size(space, anyset):
-    """Return the length of a set or frozenset object. Equivalent to
-    len(anyset).  Raises a PyExc_SystemError if anyset is not a set, frozenset,
-    or an instance of a subtype.
-
-    This function returned an int. This might require changes in
-    your code for properly supporting 64-bit systems."""
-    raise NotImplementedError
-
- at cpython_api([PyObject], Py_ssize_t, error=-1)
-def PySet_GET_SIZE(space, anyset):
-    """Macro form of PySet_Size() without error checking."""
-    raise NotImplementedError
-
- at cpython_api([PyObject, PyObject], rffi.INT_real, error=-1)
-def PySet_Add(space, set, key):
-    """Add key to a set instance.  Does not apply to frozenset
-    instances.  Return 0 on success or -1 on failure. Raise a TypeError if
-    the key is unhashable. Raise a MemoryError if there is no room to grow.
-    Raise a SystemError if set is an not an instance of set or its
-    subtype.
-
-    Now works with instances of frozenset or its subtypes.
-    Like PyTuple_SetItem() in that it can be used to fill-in the
-    values of brand new frozensets before they are exposed to other code."""
-    raise NotImplementedError
-
- at cpython_api([PyObject, PyObject], rffi.INT_real, error=-1)
-def PySet_Discard(space, set, key):
-    """Return 1 if found and removed, 0 if not found (no action taken), and -1 if an
-    error is encountered.  Does not raise KeyError for missing keys.  Raise a
-    TypeError if the key is unhashable.  Unlike the Python discard()
-    method, this function does not automatically convert unhashable sets into
-    temporary frozensets. Raise PyExc_SystemError if set is an not an
-    instance of set or its subtype."""
-    raise NotImplementedError
-
 @cpython_api([PyObject], PyObject)
 def PySet_Pop(space, set):
     """Return a new reference to an arbitrary object in the set, and removes the
@@ -2669,12 +2616,6 @@
     use the default error handling."""
     raise NotImplementedError
 
- at cpython_api([PyObject, PyObject], PyObject)
-def PyUnicode_Join(space, separator, seq):
-    """Join a sequence of strings using the given separator and return the resulting
-    Unicode string."""
-    raise NotImplementedError
-
 @cpython_api([PyObject, PyObject, Py_ssize_t, Py_ssize_t, rffi.INT_real], rffi.INT_real, error=-1)
 def PyUnicode_Tailmatch(space, str, substr, start, end, direction):
     """Return 1 if substr matches str*[*start:end] at the given tail end
@@ -2737,12 +2678,6 @@
     Py_NE, Py_LT, and Py_LE."""
     raise NotImplementedError
 
- at cpython_api([PyObject, PyObject], PyObject)
-def PyUnicode_Format(space, format, args):
-    """Return a new string object from format and args; this is analogous to
-    format % args.  The args argument must be a tuple."""
-    raise NotImplementedError
-
 @cpython_api([PyObject, PyObject], rffi.INT_real, error=-1)
 def PyUnicode_Contains(space, container, element):
     """Check whether element is contained in container and return true or false
@@ -2996,11 +2931,3 @@
     None, or NULL, this will return NULL and raise TypeError.
     """
     raise NotImplementedError
-
- at cpython_api([PyObject], PyObject)
-def PyWeakref_GET_OBJECT(space, ref):
-    """Similar to PyWeakref_GetObject(), but implemented as a macro that does no
-    error checking.
-    """
-    borrow_from()
-    raise NotImplementedError
diff --git a/pypy/module/cpyext/unicodeobject.py b/pypy/module/cpyext/unicodeobject.py
--- a/pypy/module/cpyext/unicodeobject.py
+++ b/pypy/module/cpyext/unicodeobject.py
@@ -558,8 +558,12 @@
 
 @cpython_api([PyObject, PyObject], PyObject)
 def PyUnicode_Format(space, w_format, w_args):
+    """Return a new string object from format and args; this is analogous to
+    format % args.  The args argument must be a tuple."""
     return space.mod(w_format, w_args)
 
 @cpython_api([PyObject, PyObject], PyObject)
 def PyUnicode_Join(space, w_sep, w_seq):
+    """Join a sequence of strings using the given separator and return the resulting
+    Unicode string."""
     return space.call_method(w_sep, 'join', w_seq)
diff --git a/pypy/module/cpyext/weakrefobject.py b/pypy/module/cpyext/weakrefobject.py
--- a/pypy/module/cpyext/weakrefobject.py
+++ b/pypy/module/cpyext/weakrefobject.py
@@ -25,6 +25,9 @@
 
 @cpython_api([PyObject], PyObject)
 def PyWeakref_GET_OBJECT(space, w_ref):
+    """Similar to PyWeakref_GetObject(), but implemented as a macro that does no
+    error checking.
+    """
     return borrow_from(w_ref, space.call_function(w_ref))
 
 @cpython_api([PyObject], PyObject)


More information about the pypy-commit mailing list