[pypy-svn] r74535 - in pypy/trunk/pypy/module/cpyext: . test
afa at codespeak.net
afa at codespeak.net
Mon May 17 19:26:11 CEST 2010
Author: afa
Date: Mon May 17 19:26:10 2010
New Revision: 74535
Modified:
pypy/trunk/pypy/module/cpyext/longobject.py
pypy/trunk/pypy/module/cpyext/stubsactive.py
pypy/trunk/pypy/module/cpyext/test/test_longobject.py
Log:
Implement PyLong_FromUnsignedLong, don't know why it was put into "stubsactive"
Modified: pypy/trunk/pypy/module/cpyext/longobject.py
==============================================================================
--- pypy/trunk/pypy/module/cpyext/longobject.py (original)
+++ pypy/trunk/pypy/module/cpyext/longobject.py Mon May 17 19:26:10 2010
@@ -18,6 +18,12 @@
on failure."""
return space.wrap(val)
+ at cpython_api([rffi.ULONG], PyObject)
+def PyLong_FromUnsignedLong(space, val):
+ """Return a new PyLongObject object from a C unsigned long, or
+ NULL on failure."""
+ return space.wrap(val)
+
@cpython_api([rffi.ULONGLONG], PyObject)
def PyLong_FromUnsignedLongLong(space, val):
"""Return a new PyLongObject object from a C unsigned long long,
Modified: pypy/trunk/pypy/module/cpyext/stubsactive.py
==============================================================================
--- pypy/trunk/pypy/module/cpyext/stubsactive.py (original)
+++ pypy/trunk/pypy/module/cpyext/stubsactive.py Mon May 17 19:26:10 2010
@@ -13,12 +13,6 @@
PyFile_DecUseCount() functions described below as appropriate."""
raise NotImplementedError
- at cpython_api([rffi.ULONG], PyObject)
-def PyLong_FromUnsignedLong(space, v):
- """Return a new PyLongObject object from a C unsigned long, or
- NULL on failure."""
- raise NotImplementedError
-
FILE = rffi.VOIDP_real.TO
FILEP = lltype.Ptr(FILE)
@cpython_api([PyObject, FILEP, rffi.INT_real], rffi.INT_real, error=-1)
Modified: pypy/trunk/pypy/module/cpyext/test/test_longobject.py
==============================================================================
--- pypy/trunk/pypy/module/cpyext/test/test_longobject.py (original)
+++ pypy/trunk/pypy/module/cpyext/test/test_longobject.py Mon May 17 19:26:10 2010
@@ -70,6 +70,14 @@
assert api.PyLong_AsVoidPtr(w_l) == lltype.nullptr(rffi.VOIDP_real.TO)
class AppTestLongObject(AppTestCpythonExtensionBase):
+ def test_fromunsignedlong(self):
+ module = self.import_extension('foo', [
+ ("from_unsignedlong", "METH_NOARGS",
+ """
+ return PyLong_FromUnsignedLong((unsigned long)-1);
+ """)])
+ assert module.from_unsignedlong() == (1<<32) - 1
+
def test_fromlonglong(self):
module = self.import_extension('foo', [
("from_longlong", "METH_NOARGS",
More information about the Pypy-commit
mailing list