Author: Matti Picus <[email protected]>
Branch: pypy-pyarray
Changeset: r66969:d09d00f0417d
Date: 2013-09-13 10:51 +0300
http://bitbucket.org/pypy/pypy/changeset/d09d00f0417d/
Log: refactor redundant function defs
diff --git a/pypy/module/cpyext/number.py b/pypy/module/cpyext/number.py
--- a/pypy/module/cpyext/number.py
+++ b/pypy/module/cpyext/number.py
@@ -58,8 +58,9 @@
@cpython_api([PyObjectP, PyObjectP], rffi.INT_real, error=-1)
def PyNumber_CoerceEx(space, pp1, pp2):
- """
- """
+ """This function is similar to PyNumber_Coerce(), except that it returns
+ 1 when the conversion is not possible and when no error is raised.
+ Reference counts are still not increased in this case."""
w_obj1 = from_ref(space, pp1[0])
w_obj2 = from_ref(space, pp2[0])
w_res = space.try_coerce(w_obj1, w_obj2)
@@ -74,13 +75,19 @@
@cpython_api([PyObjectP, PyObjectP], rffi.INT_real, error=-1)
def PyNumber_Coerce(space, pp1, pp2):
- """
- """
+ """This function takes the addresses of two variables of type PyObject*.
If
+ the objects pointed to by *p1 and *p2 have the same type, increment their
+ reference count and return 0 (success). If the objects can be converted to
a
+ common numeric type, replace *p1 and *p2 by their converted value (with
+ 'new' reference counts), and return 0. If no conversion is possible, or if
+ some other error occurs, return -1 (failure) and don't increment the
+ reference counts. The call PyNumber_Coerce(&o1, &o2) is equivalent to the
+ Python statement o1, o2 = coerce(o1, o2)."""
w_obj1 = from_ref(space, pp1[0])
w_obj2 = from_ref(space, pp2[0])
w_res = space.coerce(w_obj1, w_obj2)
if w_res is None:
- return 1
+ return -1
else:
Py_DecRef(space, pp1[0])
Py_DecRef(space, pp2[0])
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
@@ -1528,25 +1528,6 @@
"""
raise NotImplementedError
-@cpython_api([PyObjectP, PyObjectP], rffi.INT_real, error=-1)
-def PyNumber_Coerce(space, p1, p2):
- """This function takes the addresses of two variables of type PyObject*.
If
- the objects pointed to by *p1 and *p2 have the same type, increment their
- reference count and return 0 (success). If the objects can be converted to
a
- common numeric type, replace *p1 and *p2 by their converted value (with
- 'new' reference counts), and return 0. If no conversion is possible, or if
- some other error occurs, return -1 (failure) and don't increment the
- reference counts. The call PyNumber_Coerce(&o1, &o2) is equivalent to the
- Python statement o1, o2 = coerce(o1, o2)."""
- raise NotImplementedError
-
-@cpython_api([PyObjectP, PyObjectP], rffi.INT_real, error=-1)
-def PyNumber_CoerceEx(space, p1, p2):
- """This function is similar to PyNumber_Coerce(), except that it returns
- 1 when the conversion is not possible and when no error is raised.
- Reference counts are still not increased in this case."""
- raise NotImplementedError
-
@cpython_api([PyObject, rffi.INT_real], PyObject)
def PyNumber_ToBase(space, n, base):
"""Returns the integer n converted to base as a string with a base
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit