diff options
Diffstat (limited to 'lib/sqlalchemy/orm/util.py')
| -rw-r--r-- | lib/sqlalchemy/orm/util.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/sqlalchemy/orm/util.py b/lib/sqlalchemy/orm/util.py index 35cb0bdf5..30a8a8084 100644 --- a/lib/sqlalchemy/orm/util.py +++ b/lib/sqlalchemy/orm/util.py @@ -120,7 +120,7 @@ def polymorphic_union(table_map, typecolname, colnames = util.OrderedSet() colnamemaps = {} types = {} - for key in table_map.keys(): + for key in list(table_map.keys()): table = table_map[key] # mysql doesnt like selecting from a select; @@ -146,7 +146,7 @@ def polymorphic_union(table_map, typecolname, return sql.type_coerce(sql.null(), types[name]).label(name) result = [] - for type, table in table_map.iteritems(): + for type, table in table_map.items(): if typecolname is not None: result.append( sql.select([col(name, table) for name in colnames] + @@ -203,7 +203,7 @@ def identity_key(*args, **kwargs): "positional arguments, got %s" % len(args)) if kwargs: raise sa_exc.ArgumentError("unknown keyword arguments: %s" - % ", ".join(kwargs.keys())) + % ", ".join(list(kwargs.keys()))) mapper = class_mapper(class_) if "ident" in locals(): return mapper.identity_key_from_primary_key(util.to_list(ident)) @@ -211,7 +211,7 @@ def identity_key(*args, **kwargs): instance = kwargs.pop("instance") if kwargs: raise sa_exc.ArgumentError("unknown keyword arguments: %s" - % ", ".join(kwargs.keys())) + % ", ".join(list(kwargs.keys()))) mapper = object_mapper(instance) return mapper.identity_key_from_instance(instance) @@ -300,7 +300,7 @@ class PathRegistry(object): def pairs(self): path = self.path - for i in xrange(0, len(path), 2): + for i in range(0, len(path), 2): yield path[i], path[i + 1] def contains_mapper(self, mapper): @@ -314,10 +314,10 @@ class PathRegistry(object): def serialize(self): path = self.path - return zip( + return list(zip( [m.class_ for m in [path[i] for i in range(0, len(path), 2)]], [path[i].key for i in range(1, len(path), 2)] + [None] - ) + )) @classmethod def deserialize(cls, path): @@ -411,7 +411,7 @@ class EntityRegistry(PathRegistry, dict): self.path = parent.path + (entity,) - def __nonzero__(self): + def __bool__(self): return True def __getitem__(self, entity): @@ -589,8 +589,8 @@ class AliasedClass(object): return self.__adapt_prop(attr, key) elif hasattr(attr, 'func_code'): is_method = getattr(self.__target, key, None) - if is_method and is_method.im_self is not None: - return util.types.MethodType(attr.im_func, self, self) + if is_method and is_method.__self__ is not None: + return util.types.MethodType(attr.__func__, self, self) else: return None elif hasattr(attr, '__get__'): @@ -880,7 +880,7 @@ class _ORMJoin(expression.Join): self._joined_from_info = right_info - if isinstance(onclause, basestring): + if isinstance(onclause, str): onclause = getattr(left_orm_info.entity, onclause) if isinstance(onclause, attributes.QueryableAttribute): @@ -1001,7 +1001,7 @@ def with_parent(instance, prop): parent/child relationship. """ - if isinstance(prop, basestring): + if isinstance(prop, str): mapper = object_mapper(instance) prop = getattr(mapper.class_, prop).property elif isinstance(prop, attributes.QueryableAttribute): |
