Opened 10 years ago
Closed 10 years ago
#23346 closed Bug (fixed)
django.utils.functional.lazy picks the wrong method implementation
Reported by: | Gavin Wahl | Owned by: | nobody |
---|---|---|---|
Component: | Core (Other) | Version: | 1.6 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When a subclass of resultclasses is returned by the wrapped function, method implementaions are looked up on the base class (the one in resultclasses), not on the object actually returned.
def test_lazy_base_class_override(self): """Test that lazy finds the correct (overridden) method implementation""" class Base(object): def method(self): return 'Base' class Klazz(Base): def method(self): return 'Klazz' t = lazy(lambda: Klazz(), Base)() self.assertEqual(t.method(), 'Klazz')
In the current implementation, Base.method
will be called, not Klazz.method
.
Change History (3)
comment:1 by , 10 years ago
Has patch: | set |
---|
comment:2 by , 10 years ago
Component: | Uncategorized → Core (Other) |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Bug |
I think if we can simplify and fix lazy
, it is a good thing. However, as it is a bit magic code, it would be nice if it could still be reviewed by a Python guru.
comment:3 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
https://github.com/django/django/pull/3104