Author: Amaury Forgeot d'Arc <[email protected]>
Branch:
Changeset: r54849:f4fd4ab5e166
Date: 2012-05-01 00:01 +0200
http://bitbucket.org/pypy/pypy/changeset/f4fd4ab5e166/
Log: cpyext: add PyLong_FromSsize_t()
diff --git a/pypy/module/cpyext/longobject.py b/pypy/module/cpyext/longobject.py
--- a/pypy/module/cpyext/longobject.py
+++ b/pypy/module/cpyext/longobject.py
@@ -16,6 +16,13 @@
"""Return a new PyLongObject object from v, or NULL on failure."""
return space.newlong(val)
+@cpython_api([Py_ssize_t], PyObject)
+def PyLong_FromSsize_t(space, val):
+ """Return a new PyLongObject object from a C Py_ssize_t, or
+ NULL on failure.
+ """
+ return space.newlong(val)
+
@cpython_api([rffi.LONGLONG], PyObject)
def PyLong_FromLongLong(space, val):
"""Return a new PyLongObject object from a C long long, or NULL
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
@@ -1405,13 +1405,6 @@
"""
raise NotImplementedError
-@cpython_api([Py_ssize_t], PyObject)
-def PyLong_FromSsize_t(space, v):
- """Return a new PyLongObject object from a C Py_ssize_t, or
- NULL on failure.
- """
- raise NotImplementedError
-
@cpython_api([rffi.SIZE_T], PyObject)
def PyLong_FromSize_t(space, v):
"""Return a new PyLongObject object from a C size_t, or
diff --git a/pypy/module/cpyext/test/test_longobject.py
b/pypy/module/cpyext/test/test_longobject.py
--- a/pypy/module/cpyext/test/test_longobject.py
+++ b/pypy/module/cpyext/test/test_longobject.py
@@ -35,6 +35,7 @@
w_value = space.newlong(2)
value = api.PyLong_AsSsize_t(w_value)
assert value == 2
+ assert space.eq_w(w_value, api.PyLong_FromSsize_t(2))
def test_fromdouble(self, space, api):
w_value = api.PyLong_FromDouble(-12.74)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit