From: Robert Bradshaw Date: Wed, 30 Apr 2008 17:25:18 +0000 (-0700) Subject: Force tuple creation for generic append. X-Git-Tag: 0.9.6.14~7 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ff56ee9a64e102b1d23de88042daab95faf6df29;p=cython.git Force tuple creation for generic append. --- diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 1d656f95..491d0b8b 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -4131,7 +4131,7 @@ static inline PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) { return Py_None; // this is just to have an accurate signature } else { - return PyObject_CallMethod(L, "append", "O", x); + return PyObject_CallMethod(L, "append", "(O)", x); } } ""","" diff --git a/tests/run/append.pyx b/tests/run/append.pyx index b802dc1c..3967647e 100644 --- a/tests/run/append.pyx +++ b/tests/run/append.pyx @@ -3,19 +3,21 @@ __doc__ = """ None None got error -[1, 2] ->>> test_append(A()) # doctest: +ELLIPSIS +[1, 2, (3, 4)] +>>> _ = test_append(A()) appending 1 appending 2 +appending +(3, 4) got error - >>> test_append(B()) None None None -[1, 2, 3, 4] +None +[1, 2, (3, 4), 5, 6] """ class A: @@ -31,9 +33,10 @@ class B(list): def test_append(L): print L.append(1) print L.append(2) + print L.append((3,4)) try: - print L.append(3,4) + print L.append(5,6) except TypeError: print "got error" - print L + return L