From: Mike Bayer Date: Mon, 27 May 2013 21:15:30 +0000 (-0400) Subject: - run the whole test suite with the "debugging" ordered dict on, X-Git-Tag: rel_0_9_0b1~304^2~13^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=73404e36836a0f53be9ffe28006b8492be7b0190;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - run the whole test suite with the "debugging" ordered dict on, find some more failures --- diff --git a/lib/sqlalchemy/util/_collections.py b/lib/sqlalchemy/util/_collections.py index 5991fc8a44..689a6756b2 100644 --- a/lib/sqlalchemy/util/_collections.py +++ b/lib/sqlalchemy/util/_collections.py @@ -143,7 +143,7 @@ class Properties(object): return len(self._data) def __iter__(self): - return iter(self._data.values()) + return iter(list(self._data.values())) def __add__(self, other): return list(self) + list(other) @@ -262,13 +262,6 @@ class OrderedDict(dict): return iter(self._list) - #def __iter__(self): - # len_ = len(self._list) - # for item in self._list: - # yield item - # assert len_ == len(self._list), \ - # "Dictionary changed size during iteration" - if py2k: def values(self): return [self[key] for key in self._list] @@ -300,6 +293,24 @@ class OrderedDict(dict): #return ((key, self[key]) for key in self) return ((key, self[key]) for key in self._list) + _debug_iter = False + if _debug_iter: + # normally disabled to reduce function call + # overhead + def __iter__(self): + len_ = len(self._list) + for item in self._list: + yield item + assert len_ == len(self._list), \ + "Dictionary changed size during iteration" + def values(self): + return (self[key] for key in self) + def keys(self): + return iter(self) + def items(self): + return ((key, self[key]) for key in self) + + def __setitem__(self, key, object): if key not in self: try: