Skip to content

Commit

Permalink
Over-ride pyset in PyTuple so our tuples go back to being immutable. …
Browse files Browse the repository at this point in the history
  • Loading branch information
fwierzbicki committed Jan 23, 2009
1 parent e42e8ff commit 2490b8e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Lib/test/test_tuple.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ def test_repr(self):
self.assertEqual(repr(a0), "()")
self.assertEqual(repr(a2), "(0, 1, 2)")

def test_setitem(self):
#This test is equivalent to (1,2)[0] = 0 which was briefly broken in
#Jython 2.5b2
import operator
self.assertRaises(TypeError, operator.setitem, (1,2), 0, 0)

def test_main():
test_support.run_unittest(TupleTest)

Expand Down
5 changes: 5 additions & 0 deletions src/org/python/core/PyTuple.java
Original file line number Diff line number Diff line change
Expand Up @@ -384,4 +384,9 @@ protected String unsupportedopMessage(String op, PyObject o2) {
}
return super.unsupportedopMessage(op, o2);
}

public void pyset(int index, PyObject value) {
throw Py.TypeError("'tuple' object does not support item assignment");
}

}

0 comments on commit 2490b8e

Please sign in to comment.