[pypy-svn] r73585 - in pypy/branch/cpython-extension/pypy/module/cpyext: . test
trundle at codespeak.net
trundle at codespeak.net
Fri Apr 9 14:54:19 CEST 2010
Author: trundle
Date: Fri Apr 9 14:54:16 2010
New Revision: 73585
Modified:
pypy/branch/cpython-extension/pypy/module/cpyext/intobject.py
pypy/branch/cpython-extension/pypy/module/cpyext/test/test_intobject.py
Log:
Fix PyInt_AsLong (coercion).
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/intobject.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/intobject.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/intobject.py Fri Apr 9 14:54:16 2010
@@ -19,7 +19,7 @@
already one, and then return its value. If there is an error, -1 is
returned, and the caller should check PyErr_Occurred() to find out whether
there was an error, or whether the value just happened to be -1."""
- return space.int_w(w_obj)
+ return space.int_w(space.int(w_obj))
@cpython_api([PyObject], lltype.Signed, error=CANNOT_FAIL)
def PyInt_AS_LONG(space, w_int):
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/test/test_intobject.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/test/test_intobject.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/test_intobject.py Fri Apr 9 14:54:16 2010
@@ -18,3 +18,9 @@
assert api.PyInt_AsLong(space.w_None) == -1
assert api.PyErr_Occurred() is space.w_TypeError
api.PyErr_Clear()
+
+ def test_coerce(self, space, api):
+ class Coerce(object):
+ def __int__(self):
+ return 42
+ assert api.PyInt_AsLong(space.wrap(Coerce())) == 42
More information about the Pypy-commit
mailing list