On 27 Sep, 08:32, Duncan Booth <[EMAIL PROTECTED]> wrote: > Paul Hankin <[EMAIL PROTECTED]> wrote: > >> A key which is in dict must be either in __keycache or in __addkeys, but > >> never in both. > > > Yes, I'm sorry: you're right. > > > But there's a different bug: if you delete a key that's not in the > > dict, you'll add it to the deleted list before the exception for the > > missing key is raised. > > > sd = sorteddict.sorteddict() > > sd['a'] = 'a' > > print sd.keys() = ['a'] > > try: > > del sd['b'] > > except: > > pass > > sd['b'] = 'b' > > print sd.keys() > > > The second print statement produces ['a'] rather than ['a', 'b'] > > Yes, I think there are probably several cases where I need to account for > exceptions. > > There's another serious problem: if Mark wants this module to be used and > stand any chance at all of eventually being incorporated into the standard > library, then he will have to change the license on his code: the GPL > simply isn't an option here.
I have fixed __addkey() and __removekey(): def __addkey(self, key): if key in self.__delkeys: self.__delkeys.remove(key) else: self.__addkeys.add(key) def __removekey(self, key): if key in self.__addkeys: self.__addkeys.remove(key) else: self.__delkeys.add(key) I have also fixed __delitem__(): try: dict.__delitem__(self, key) except KeyError: raise else: self.__removekey(key) As for the license, while it is on PyPI, I'll leave it as GPL v 3. If it was wanted for the standard library (and I can't see that ever happening), I will happily change it to the one that is preferred for Python modules. -- http://mail.python.org/mailman/listinfo/python-list