[pypy-svn] r74079 - in pypy/branch/cpython-extension/pypy/module/cpyext: . test

afa at codespeak.net afa at codespeak.net
Mon Apr 26 16:59:30 CEST 2010


Author: afa
Date: Mon Apr 26 16:59:28 2010
New Revision: 74079

Modified:
   pypy/branch/cpython-extension/pypy/module/cpyext/number.py
   pypy/branch/cpython-extension/pypy/module/cpyext/stubs.py
   pypy/branch/cpython-extension/pypy/module/cpyext/test/test_number.py
Log:
PyNumber_Int


Modified: pypy/branch/cpython-extension/pypy/module/cpyext/number.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/number.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/number.py	Mon Apr 26 16:59:28 2010
@@ -38,6 +38,13 @@
     return space.int_w(w_obj) #XXX: this is wrong on win64
 
 @cpython_api([PyObject], PyObject)
+def PyNumber_Int(space, w_obj):
+    """Returns the o converted to an integer object on success, or NULL on failure.
+    If the argument is outside the integer range a long object will be returned
+    instead. This is the equivalent of the Python expression int(o)."""
+    return space.int(w_obj)
+
+ at cpython_api([PyObject], PyObject)
 def PyNumber_Long(space, w_obj):
     """    Returns the o converted to a long integer object on success, or NULL on
     failure.  This is the equivalent of the Python expression long(o)."""

Modified: pypy/branch/cpython-extension/pypy/module/cpyext/stubs.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/stubs.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/stubs.py	Mon Apr 26 16:59:28 2010
@@ -3693,17 +3693,6 @@
     raise NotImplementedError
 
 @cpython_api([PyObject], PyObject)
-def PyNumber_Int(space, o):
-    """
-    
-    
-    
-    Returns the o converted to an integer object on success, or NULL on failure.
-    If the argument is outside the integer range a long object will be returned
-    instead. This is the equivalent of the Python expression int(o)."""
-    raise NotImplementedError
-
- at cpython_api([PyObject], PyObject)
 def PyNumber_Index(space, o):
     """Returns the o converted to a Python int or long on success or NULL with a
     TypeError exception raised on failure.

Modified: pypy/branch/cpython-extension/pypy/module/cpyext/test/test_number.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/test/test_number.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/test_number.py	Mon Apr 26 16:59:28 2010
@@ -20,6 +20,10 @@
         w_l = api.PyNumber_Long(space.wrap(123))
         assert api.PyLong_CheckExact(w_l)
 
+    def test_number_int(self, space, api):
+        w_l = api.PyNumber_Int(space.wrap(123L))
+        assert api.PyInt_CheckExact(w_l)
+
     def test_numbermethods(self, space, api):
         assert "ab" == space.unwrap(
             api.PyNumber_Add(space.wrap("a"), space.wrap("b")))



More information about the Pypy-commit mailing list