diff options
Diffstat (limited to 'lib/sqlalchemy/ext/associationproxy.py')
| -rw-r--r-- | lib/sqlalchemy/ext/associationproxy.py | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/lib/sqlalchemy/ext/associationproxy.py b/lib/sqlalchemy/ext/associationproxy.py index 252efcb42..ad09db831 100644 --- a/lib/sqlalchemy/ext/associationproxy.py +++ b/lib/sqlalchemy/ext/associationproxy.py @@ -475,7 +475,7 @@ class _AssociationCollection(object): def __len__(self): return len(self.col) - def __nonzero__(self): + def __bool__(self): return bool(self.col) def __getstate__(self): @@ -514,7 +514,7 @@ class _AssociationList(_AssociationCollection): stop = index.stop step = index.step or 1 - rng = range(index.start or 0, stop, step) + rng = list(range(index.start or 0, stop, step)) if step == 1: for i in rng: del self[index.start] @@ -569,7 +569,7 @@ class _AssociationList(_AssociationCollection): def count(self, value): return sum([1 for _ in - itertools.ifilter(lambda v: v == value, iter(self))]) + filter(lambda v: v == value, iter(self))]) def extend(self, values): for v in values: @@ -668,8 +668,8 @@ class _AssociationList(_AssociationCollection): def __hash__(self): raise TypeError("%s objects are unhashable" % type(self).__name__) - for func_name, func in locals().items(): - if (util.callable(func) and func.func_name == func_name and + for func_name, func in list(locals().items()): + if (util.callable(func) and func.__name__ == func_name and not func.__doc__ and hasattr(list, func_name)): func.__doc__ = getattr(list, func_name).__doc__ del func_name, func @@ -711,7 +711,7 @@ class _AssociationDict(_AssociationCollection): return key in self.col def __iter__(self): - return self.col.iterkeys() + return iter(self.col.keys()) def clear(self): self.col.clear() @@ -738,7 +738,7 @@ class _AssociationDict(_AssociationCollection): return cmp(dict(self), other) def __repr__(self): - return repr(dict(self.items())) + return repr(dict(list(self.items()))) def get(self, key, default=None): try: @@ -754,13 +754,13 @@ class _AssociationDict(_AssociationCollection): return self[key] def keys(self): - return self.col.keys() + return list(self.col.keys()) def iterkeys(self): - return self.col.iterkeys() + return iter(self.col.keys()) def values(self): - return [self._get(member) for member in self.col.values()] + return [self._get(member) for member in list(self.col.values())] def itervalues(self): for key in self.col: @@ -811,13 +811,13 @@ class _AssociationDict(_AssociationCollection): self[key] = value def copy(self): - return dict(self.items()) + return dict(list(self.items())) def __hash__(self): raise TypeError("%s objects are unhashable" % type(self).__name__) - for func_name, func in locals().items(): - if (util.callable(func) and func.func_name == func_name and + for func_name, func in list(locals().items()): + if (util.callable(func) and func.__name__ == func_name and not func.__doc__ and hasattr(dict, func_name)): func.__doc__ = getattr(dict, func_name).__doc__ del func_name, func @@ -838,7 +838,7 @@ class _AssociationSet(_AssociationCollection): def __len__(self): return len(self.col) - def __nonzero__(self): + def __bool__(self): if self.col: return True else: @@ -1014,8 +1014,8 @@ class _AssociationSet(_AssociationCollection): def __hash__(self): raise TypeError("%s objects are unhashable" % type(self).__name__) - for func_name, func in locals().items(): - if (util.callable(func) and func.func_name == func_name and + for func_name, func in list(locals().items()): + if (util.callable(func) and func.__name__ == func_name and not func.__doc__ and hasattr(set, func_name)): func.__doc__ = getattr(set, func_name).__doc__ del func_name, func |
