#26287: SimpleLazyObject doesn't implement __radd__
-----------------------------+--------------------
Reporter: kezabelle | Owner: nobody
Type: New feature | Status: new
Component: Utilities | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+--------------------
Technically, there's a whole bunch of magic methods it doesn't implement,
compared to a ''complete'' proxy implementation, like that of
`wrapt.ObjectProxy`, but `__radd__` being missing is the one that's biting
me at the moment.
As far as I can tell, the implementation can't just be
{{{
__radd__ = new_method_proxy(operator.radd)
}}}
because that doesn't exist, which is rubbish.
{{{
__radd__ = new_method_proxy(operator.attrgetter("__radd__"))
}}}
also won't work because types may not have that attr, and attrgetter
doesn't supress the exception (correctly)
The minimal implementation I've found that works for me is:
{{{
def __radd__(self, other):
if self._wrapped is empty:
self._setup()
return other + self._wrapped
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26287>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.fd84c9ab900d9edf120477ef910b24dc%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.