Author: Matti Picus <matti.pi...@gmail.com> Branch: Changeset: r91439:b17c6b5755f2 Date: 2017-05-30 09:44 +0300 http://bitbucket.org/pypy/pypy/changeset/b17c6b5755f2/
Log: expand test, fix translation diff --git a/pypy/module/cpyext/test/test_tupleobject.py b/pypy/module/cpyext/test/test_tupleobject.py --- a/pypy/module/cpyext/test/test_tupleobject.py +++ b/pypy/module/cpyext/test/test_tupleobject.py @@ -164,12 +164,20 @@ def test_setitem(self): module = self.import_extension('foo', [ - ("set_after_use", "METH_NOARGS", + ("set_after_use", "METH_O", """ PyObject *t2, *tuple = PyTuple_New(1); PyObject * one = PyLong_FromLong(1); + int res; Py_INCREF(one); - int res = PyTuple_SetItem(tuple, 0, one); + res = PyTuple_SetItem(tuple, 0, one); + if (res != 0) + { + Py_DECREF(tuple); + return NULL; + } + Py_INCREF(args); + res = PyTuple_SetItem(tuple, 0, args); if (res != 0) { Py_DECREF(tuple); @@ -191,8 +199,9 @@ """), ]) import sys + s = 'abc' if '__pypy__' in sys.builtin_module_names: - raises(SystemError, module.set_after_use) + raises(SystemError, module.set_after_use, s) else: - module.set_after_use() + module.set_after_use(s) diff --git a/pypy/module/cpyext/tupleobject.py b/pypy/module/cpyext/tupleobject.py --- a/pypy/module/cpyext/tupleobject.py +++ b/pypy/module/cpyext/tupleobject.py @@ -135,17 +135,17 @@ if not tuple_check_ref(space, ref): decref(space, py_obj) PyErr_BadInternalCall(space) - ref = rffi.cast(PyTupleObject, ref) - size = ref.c_ob_size + tupleobj = rffi.cast(PyTupleObject, ref) + size = tupleobj.c_ob_size if index < 0 or index >= size: decref(space, py_obj) raise oefmt(space.w_IndexError, "tuple assignment index out of range") - old_ref = ref.c_ob_item[index] + old_ref = tupleobj.c_ob_item[index] if pyobj_has_w_obj(ref): # similar but not quite equal to ref.c_ob_refcnt != 1 on CPython raise oefmt(space.w_SystemError, "PyTuple_SetItem called on tuple after" " use of tuple") - ref.c_ob_item[index] = py_obj # consumes a reference + tupleobj.c_ob_item[index] = py_obj # consumes a reference if old_ref: decref(space, old_ref) return 0 _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit