#26311: Clean django.contrib.admin.widgets.RelatedFieldWidgetWrapper.__deepcopy__ -------------------------------+-------------------- Reporter: jpic | Owner: nobody Type: Uncategorized | Status: new Component: Uncategorized | Version: 1.9 Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------+-------------------- Currently, django.contrib.admin.widget.RelatedFieldWidgetWrapper defines:
{{{ def __deepcopy__(self, memo): obj = copy.copy(self) obj.widget = copy.deepcopy(self.widget, memo) obj.attrs = self.widget.attrs memo[id(self)] = obj return obj }}} I tried to run the tests (with python3 runtests.py admin*) after removing that, and it seemed like it didn't break anything. So my first question is: what use case is this meant to support ? Is that use case tested ? Also, RelatedFieldWidgetWrapper inherits from Widget, which defines: {{{ def __deepcopy__(self, memo): obj = copy.copy(self) obj.attrs = self.attrs.copy() memo[id(self)] = obj return obj }}} Question is: can we change RelatedFieldWidgetWrapper.__deepcopy__ to: {{{ def __deepcopy__(self, memo): obj = super(RelatedFieldWidgetWrapper, self).__deepcopy__(memo) copy.copy(self) obj.widget = copy.deepcopy(self.widget, memo) return obj }}} Like in MultiWidgets, which has: {{{ def __deepcopy__(self, memo): obj = super(MultiWidget, self).__deepcopy__(memo) obj.widgets = copy.deepcopy(self.widgets) return obj }}} Another problem I found is that it didn't seem to break any test to just remove RelatedFieldWidgetWrapper.__deepcopy__. Is it tested anywhere ? Or should we add a test for that too ? -- Ticket URL: <https://code.djangoproject.com/ticket/26311> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/047.b202d52f8aefc1248cf94707a09e68e6%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.