[pypy-svn] r79909 - in pypy/branch/psycopg2compatibility/pypy/module/cpyext: . test
dan at codespeak.net
dan at codespeak.net
Wed Dec 8 19:40:53 CET 2010
Author: dan
Date: Wed Dec 8 19:40:51 2010
New Revision: 79909
Modified:
pypy/branch/psycopg2compatibility/pypy/module/cpyext/sequence.py
pypy/branch/psycopg2compatibility/pypy/module/cpyext/test/test_sequence.py
Log:
Using PyErr_\* to test for exceptions in the test, don't incref value.
Modified: pypy/branch/psycopg2compatibility/pypy/module/cpyext/sequence.py
==============================================================================
--- pypy/branch/psycopg2compatibility/pypy/module/cpyext/sequence.py (original)
+++ pypy/branch/psycopg2compatibility/pypy/module/cpyext/sequence.py Wed Dec 8 19:40:51 2010
@@ -136,10 +136,5 @@
This function used an int type for i. This might require
changes in your code for properly supporting 64-bit systems."""
- try:
- Py_IncRef(space, w_v)
- space.setitem(w_o, space.wrap(i), w_v)
- return 0
- except:
- Py_DecRef(space, w_v)
- raise
+ space.setitem(w_o, space.wrap(i), w_v)
+ return 0
Modified: pypy/branch/psycopg2compatibility/pypy/module/cpyext/test/test_sequence.py
==============================================================================
--- pypy/branch/psycopg2compatibility/pypy/module/cpyext/test/test_sequence.py (original)
+++ pypy/branch/psycopg2compatibility/pypy/module/cpyext/test/test_sequence.py Wed Dec 8 19:40:51 2010
@@ -75,8 +75,10 @@
value = api.PyInt_FromLong(42)
tup = api.PyTuple_New(1)
- exc = raises(OperationError, sequence.PySequence_SetItem, space, tup, 0, value)
- assert exc.value.match(space, space.w_TypeError)
+ result = api.PySequence_SetItem(tup, 0, value)
+ assert result == -1
+ assert api.PyErr_Occurred()
+ assert api.PyErr_ExceptionMatches(space.w_TypeError)
l = api.PyList_New(1)
@@ -84,4 +86,9 @@
assert result != -1
assert space.eq_w(space.getitem(l, space.wrap(0)), value)
- api.Py_DecRef(value)
+
+ result = api.PySequence_SetItem(l, 3, value)
+ assert result == -1
+ assert api.PyErr_Occurred()
+ assert api.PyErr_ExceptionMatches(space.w_IndexError)
+ api.PyErr_Clear()
More information about the Pypy-commit
mailing list