[pypy-commit] pypy default: merge heads
bivab
noreply at buildbot.pypy.org
Sun Mar 24 12:03:46 CET 2013
Author: David Schneider <david.schneider at picle.org>
Branch:
Changeset: r62724:9dd54c5f962d
Date: 2013-03-24 13:02 +0200
http://bitbucket.org/pypy/pypy/changeset/9dd54c5f962d/
Log: merge heads
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
@@ -23,6 +23,13 @@
"""
return space.newlong(val)
+ at cpython_api([rffi.SIZE_T], PyObject)
+def PyLong_FromSize_t(space, val):
+ """Return a new PyLongObject object from a C size_t, or NULL on
+ failure.
+ """
+ return space.wrap(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
@@ -1395,13 +1395,6 @@
"""
raise NotImplementedError
- at cpython_api([rffi.SIZE_T], PyObject)
-def PyLong_FromSize_t(space, v):
- """Return a new PyLongObject object from a C size_t, or
- NULL on failure.
- """
- raise NotImplementedError
-
@cpython_api([rffi.CWCHARP, Py_ssize_t, rffi.INT_real], PyObject)
def PyLong_FromUnicode(space, u, length, base):
"""Convert a sequence of Unicode digits to a Python long integer value. The first
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
@@ -146,6 +146,15 @@
assert module.from_longlong() == -1
assert module.from_unsignedlonglong() == (1<<64) - 1
+ def test_from_size_t(self):
+ module = self.import_extension('foo', [
+ ("from_unsignedlong", "METH_NOARGS",
+ """
+ return PyLong_FromSize_t((size_t)-1);
+ """)])
+ import sys
+ assert module.from_unsignedlong() == 2 * sys.maxint + 1
+
def test_fromstring(self):
module = self.import_extension('foo', [
("from_string", "METH_NOARGS",
More information about the pypy-commit
mailing list