#29478: cached_property decorator doesn't work with mangled method names
-------------------------------------------+------------------------
Reporter: Thomas Grainger | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 2.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------+------------------------
{{{
import itertools
from django.utils.functional import cached_property
count = itertools.count()
count2 = itertools.count()
count3 = itertools.count()
class Foo:
@cached_property
def __foo(self):
return next(count)
@cached_property
def foo2(self):
return next(count2)
@property
def foo3(self):
return next(count3)
def run(self):
print('foo', self.__foo)
print('foo', self.__foo)
print('foo', self.__foo)
print('foo', self.__foo)
print('foo2', self.foo2)
print('foo2', self.foo2)
print('foo2', self.foo2)
print('foo2', self.foo2)
print('foo2', self.foo2)
print('foo3', self.foo3)
print('foo3', self.foo3)
print('foo3', self.foo3)
print('foo3', self.foo3)
print('foo3', self.foo3)
Foo().run()
"""
python cached_property_test.py
foo 0
foo 1
foo 2
foo 3
foo2 0
foo2 0
foo2 0
foo2 0
foo2 0
foo3 0
foo3 1
foo3 2
foo3 3
foo3 4
"""
}}}
Odd it's not been reported before:
https://code.djangoproject.com/search?q=cached_property+mangled
--
Ticket URL: <https://code.djangoproject.com/ticket/29478>
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.c8be32cefcdc0046857ed6d36785cad5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.