From 14cf1b0d40d5538e79e33527a2c13eb59c04893f Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Wed, 12 Jun 2024 16:46:03 +0200 Subject: [PATCH] Remove catching of `AttributeError` in `DescriptorWrapper` This catch was introduced in #367, but subsequent discussion in #370, #381 and #382 suggests that it wasn't the proper solution. Now that `AbstractModelTrackerTests` is re-enabled and passing, it becomes clear that `AttributeError` is no longer raised during unit testing when using a recent Django version. Therefore I think it is safe to remove the `try`/`except`. --- model_utils/tracker.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/model_utils/tracker.py b/model_utils/tracker.py index 5136990..118d1ac 100644 --- a/model_utils/tracker.py +++ b/model_utils/tracker.py @@ -50,10 +50,7 @@ class DescriptorWrapper: if instance is None: return self was_deferred = self.field_name in instance.get_deferred_fields() - try: - value = self.descriptor.__get__(instance, owner) - except AttributeError: - value = self.descriptor + value = self.descriptor.__get__(instance, owner) if was_deferred: tracker_instance = getattr(instance, self.tracker_attname) tracker_instance.saved_data[self.field_name] = lightweight_deepcopy(value)