Commit ff56ee9a authored by Robert Bradshaw's avatar Robert Bradshaw

Force tuple creation for generic append.

parent 2d7dcc62
...@@ -4131,7 +4131,7 @@ static inline PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) { ...@@ -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 return Py_None; // this is just to have an accurate signature
} }
else { else {
return PyObject_CallMethod(L, "append", "O", x); return PyObject_CallMethod(L, "append", "(O)", x);
} }
} }
""","" """,""
......
...@@ -3,19 +3,21 @@ __doc__ = """ ...@@ -3,19 +3,21 @@ __doc__ = """
None None
None None
got error got error
[1, 2] [1, 2, (3, 4)]
>>> test_append(A()) # doctest: +ELLIPSIS >>> _ = test_append(A())
appending appending
1 1
appending appending
2 2
appending
(3, 4)
got error got error
<append.A instance at ...>
>>> test_append(B()) >>> test_append(B())
None None
None None
None None
[1, 2, 3, 4] None
[1, 2, (3, 4), 5, 6]
""" """
class A: class A:
...@@ -31,9 +33,10 @@ class B(list): ...@@ -31,9 +33,10 @@ class B(list):
def test_append(L): def test_append(L):
print L.append(1) print L.append(1)
print L.append(2) print L.append(2)
print L.append((3,4))
try: try:
print L.append(3,4) print L.append(5,6)
except TypeError: except TypeError:
print "got error" print "got error"
print L return L
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment