]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- remove the need for a recursive call here
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 20 Feb 2015 05:11:48 +0000 (00:11 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 20 Feb 2015 05:11:48 +0000 (00:11 -0500)
lib/sqlalchemy/orm/session.py

index a33b4261204a396b839cf78d85da5c0790d8fabf..6dc6d3755c54b6452f57324703a274b0e33e79f3 100644 (file)
@@ -237,14 +237,21 @@ class SessionTransaction(object):
             self.session, self, nested=nested)
 
     def _iterate_parents(self, upto=None):
-        if self._parent is upto:
-            return (self,)
-        else:
-            if self._parent is None:
+
+        current = self
+        result = ()
+        while current:
+            result += (current, )
+            if current._parent is upto:
+                break
+            elif current._parent is None:
                 raise sa_exc.InvalidRequestError(
                     "Transaction %s is not on the active transaction list" % (
                         upto))
-            return (self,) + self._parent._iterate_parents(upto)
+            else:
+                current = current._parent
+
+        return result
 
     def _take_snapshot(self):
         if not self._is_transaction_boundary: