Commit a4a3c368 authored by Patrick Strawderman's avatar Patrick Strawderman

Make PersistentList's sort method accept keyword parameters.

parent 8eb1d702
......@@ -25,6 +25,10 @@ Bugs Fixed
- Opening a blob with modes 'r+' or 'a' would fail when the blob had no
committed changes.
- PersistentList's sort method did not allow passing of keyword parameters.
Changed its sort parameter list to match that of its (Python 2.4+)
UserList base class.
3.9.0b5 (2009-08-06)
====================
......
......@@ -81,8 +81,8 @@ class PersistentList(UserList, persistent.Persistent):
self.__super_reverse()
self._p_changed = 1
def sort(self, *args):
self.__super_sort(*args)
def sort(self, *args, **kwargs):
self.__super_sort(*args, **kwargs)
self._p_changed = 1
def extend(self, other):
......
......@@ -217,6 +217,24 @@ class TestPList(unittest.TestCase):
u.sort()
eq(u, u2, "u == u2")
# Test keyword arguments to sort
u.sort(cmp=lambda x,y: cmp(y, x))
eq(u, [1, 0], "u == [1, 0]")
u.sort(key=lambda x:-x)
eq(u, [1, 0], "u == [1, 0]")
u.sort(reverse=True)
eq(u, [1, 0], "u == [1, 0]")
# Passing any other keyword arguments results in a TypeError
try:
u.sort(blah=True)
except TypeError:
pass
else:
raise TestFailed("expected TypeError")
# Test extend
u = u1[:]
......
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