From ff56ee9a64e102b1d23de88042daab95faf6df29 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Wed, 30 Apr 2008 10:25:18 -0700 Subject: [PATCH] Force tuple creation for generic append. --- Cython/Compiler/ExprNodes.py | 2 +- tests/run/append.pyx | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) 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 -- 2.26.2