From 1ac740761588600939d4fba31740227780022bb9 Mon Sep 17 00:00:00 2001 From: Viktor Ashirov Date: Oct 08 2019 06:49:19 +0000 Subject: Issue 50638 - RecursionError: maximum recursion depth exceeded while calling a Python object Bug Description: DSLdapObject has an overridden `__getattr__` method. In case the requested attribute doesn't exist, `getattr()` goes into an infitite recursive loop, only to be interrupted by a `RecursionError` exception. `rename()` method has one such lookup for a non-existent attribute, and it's not used at all. Fix Description: * Restore the default behaviour of `getattr()` when attribute doesn't exist. * Remove unneeded attribute lookup in `rename()`. Fixes: https://pagure.io/389-ds-base/issue/50638 Reviewed by: mreynolds, mhonek, firstyear (Thanks!) --- diff --git a/src/lib389/lib389/_mapped_object.py b/src/lib389/lib389/_mapped_object.py index 578dda0..e331b3b 100644 --- a/src/lib389/lib389/_mapped_object.py +++ b/src/lib389/lib389/_mapped_object.py @@ -197,7 +197,7 @@ class DSLdapObject(DSLogging): pfunc = partial(self._jsonify, getattr(self, int_name)) return pfunc else: - getattr(self, name) + raise AttributeError("'%s' object has no attribute '%s'" % (self.__class__.__name__, name)) # We make this a property so that we can over-ride dynamically if needed @property @@ -765,7 +765,6 @@ class DSLdapObject(DSLogging): self._instance.rename_s(self._dn, new_rdn, newsuperior, serverctrls=self._server_controls, clientctrls=self._client_controls, delold=deloldrdn, escapehatch='i am sure') - search_base = self._basedn if newsuperior is not None: # Well, the new DN should be rdn + newsuperior. self._dn = '%s,%s' % (new_rdn, newsuperior)