[c-c] fix RuntimeError: 'maximum recursion depth exceeded while calling a Python object' we get when creating/upgrading/shelling an instance: hasattr() call __getattribute__, creating an infinite recursion error catched by the interpretor. Avoid this by testing the method is available on the class instead of the instance stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 29 Sep 2010 12:44:11 +0200
branchstable
changeset 6362 1b5fc8581437
parent 6361 843684a50e48
child 6363 b9ec8ebc187a
[c-c] fix RuntimeError: 'maximum recursion depth exceeded while calling a Python object' we get when creating/upgrading/shelling an instance: hasattr() call __getattribute__, creating an infinite recursion error catched by the interpretor. Avoid this by testing the method is available on the class instead of the instance
migration.py
--- a/migration.py	Wed Sep 29 12:18:06 2010 +0200
+++ b/migration.py	Wed Sep 29 12:44:11 2010 +0200
@@ -129,7 +129,8 @@
             return object.__getattribute__(self, name)
         except AttributeError:
             cmd = 'cmd_%s' % name
-            if hasattr(self, cmd):
+            # search self.__class__ to avoid infinite recursion
+            if hasattr(self.__class__, cmd):
                 meth = getattr(self, cmd)
                 return lambda *args, **kwargs: self.interact(args, kwargs,
                                                              meth=meth)