[Django] #29478: cached_property decorator doesn't work with mangled method names

18 views
Skip to first unread message

Django

unread,
Jun 7, 2018, 6:44:26 AM6/7/18
to django-...@googlegroups.com
#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.

Django

unread,
Jun 7, 2018, 7:40:09 PM6/7/18
to django-...@googlegroups.com
#29478: cached_property decorator doesn't work with mangled method names
---------------------------------+------------------------------------

Reporter: Thomas Grainger | Owner: nobody
Type: Bug | Status: new
Component: Utilities | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Tim Graham):

* component: Uncategorized => Utilities
* needs_better_patch: 0 => 1
* has_patch: 0 => 1
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted


Comment:

[https://github.com/django/django/pull/10033 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/29478#comment:1>

Django

unread,
Jun 8, 2018, 7:23:02 AM6/8/18
to django-...@googlegroups.com
#29478: cached_property decorator doesn't work with mangled method names
---------------------------------+------------------------------------
Reporter: Thomas Grainger | Owner: hehaha
Type: Bug | Status: assigned

Component: Utilities | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by hehaha):

* status: new => assigned
* owner: nobody => hehaha


--
Ticket URL: <https://code.djangoproject.com/ticket/29478#comment:2>

Django

unread,
Jun 20, 2018, 10:36:06 PM6/20/18
to django-...@googlegroups.com
#29478: cached_property decorator doesn't work with mangled method names
---------------------------------+------------------------------------
Reporter: Thomas Grainger | Owner: (none)
Type: Bug | Status: new

Component: Utilities | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Xin He):

* status: assigned => new
* owner: Xin He => (none)


Comment:

It's seem another pull request to fix the ticket on Github. So I have to
deassign it.

--
Ticket URL: <https://code.djangoproject.com/ticket/29478#comment:3>

Django

unread,
Jun 28, 2018, 9:38:44 AM6/28/18
to django-...@googlegroups.com
#29478: cached_property decorator doesn't work with mangled method names
---------------------------------+------------------------------------

Reporter: Thomas Grainger | Owner: nobody
Type: Bug | Status: new
Component: Utilities | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------

Comment (by Harro):

Had a look at this, and the Foo instance dict does contain the __foo (and
the foo2, but not the foo3 as expected).

I think this is more a python thing where the double underscore is special
and that is the reason it doesn't work and that it has nothing to do with
the @cached_property decorator.

--
Ticket URL: <https://code.djangoproject.com/ticket/29478#comment:2>

Django

unread,
Jul 6, 2018, 7:27:56 AM7/6/18
to django-...@googlegroups.com
#29478: cached_property decorator doesn't work with mangled method names
---------------------------------+------------------------------------

Reporter: Thomas Grainger | Owner: nobody
Type: Bug | Status: new
Component: Utilities | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Thomas Grainger):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/29478#comment:3>

Django

unread,
Jul 9, 2018, 12:13:49 PM7/9/18
to django-...@googlegroups.com
#29478: cached_property decorator doesn't work with mangled method names
---------------------------------+------------------------------------

Reporter: Thomas Grainger | Owner: nobody
Type: Bug | Status: new
Component: Utilities | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"09199734d383691ecf6d163894b447ca45e0ef82" 09199734]:
{{{
#!CommitTicketReference repository=""
revision="09199734d383691ecf6d163894b447ca45e0ef82"
Refs #29478 -- Doc'd how to use cached_property with a mangled name.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29478#comment:4>

Django

unread,
Jul 9, 2018, 12:14:04 PM7/9/18
to django-...@googlegroups.com
#29478: cached_property decorator doesn't work with mangled method names
---------------------------------+------------------------------------

Reporter: Thomas Grainger | Owner: nobody
Type: Bug | Status: new
Component: Utilities | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"2a637a45232fa5f046034958a6df91804bbab32c" 2a637a45]:
{{{
#!CommitTicketReference repository=""
revision="2a637a45232fa5f046034958a6df91804bbab32c"
[2.1.x] Refs #29478 -- Doc'd how to use cached_property with a mangled
name.

Backport of 09199734d383691ecf6d163894b447ca45e0ef82 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29478#comment:5>

Django

unread,
Jul 19, 2018, 5:45:28 PM7/19/18
to django-...@googlegroups.com
#29478: cached_property decorator doesn't work with mangled method names
---------------------------------+------------------------------------

Reporter: Thomas Grainger | Owner: nobody
Type: Bug | Status: new
Component: Utilities | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Tim Graham):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/29478#comment:6>

Django

unread,
Sep 15, 2018, 8:56:21 PM9/15/18
to django-...@googlegroups.com
#29478: cached_property decorator doesn't work with mangled method names
---------------------------------+------------------------------------

Reporter: Thomas Grainger | Owner: nobody
Type: Bug | Status: new
Component: Utilities | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Tim Graham):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/29478#comment:7>

Django

unread,
Nov 16, 2018, 11:45:32 AM11/16/18
to django-...@googlegroups.com
#29478: cached_property decorator doesn't work with mangled method names
---------------------------------+------------------------------------

Reporter: Thomas Grainger | Owner: nobody
Type: Bug | Status: new
Component: Utilities | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Sergey Fedoseev):

* needs_better_patch: 1 => 0

Django

unread,
Nov 19, 2018, 9:01:34 AM11/19/18
to django-...@googlegroups.com
#29478: cached_property decorator doesn't work with mangled method names
---------------------------------+------------------------------------

Reporter: Thomas Grainger | Owner: nobody
Type: Bug | Status: new
Component: Utilities | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"80ba7a881f9810404ba8a660548f1757f8243562" 80ba7a8]:
{{{
#!CommitTicketReference repository=""
revision="80ba7a881f9810404ba8a660548f1757f8243562"
Fixed cached_properties that share a common property.

The aliases aren't cached and thus the old usage will be an error after
refs #29478.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29478#comment:8>

Django

unread,
Nov 19, 2018, 2:06:29 PM11/19/18
to django-...@googlegroups.com
#29478: cached_property decorator doesn't work with mangled method names
---------------------------------+------------------------------------

Reporter: Thomas Grainger | Owner: nobody
Type: Bug | Status: closed
Component: Utilities | Version: 2.0
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"06076999026091cf007d8ea69146340a361259f8" 06076999]:
{{{
#!CommitTicketReference repository=""
revision="06076999026091cf007d8ea69146340a361259f8"
Fixed #29478 -- Added support for mangled names to cached_property.

Co-Authored-By: Sergey Fedoseev <fedosee...@gmail.com>
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29478#comment:9>

Django

unread,
Feb 12, 2019, 6:35:07 PM2/12/19
to django-...@googlegroups.com
#29478: cached_property decorator doesn't work with mangled method names
---------------------------------+------------------------------------

Reporter: Thomas Grainger | Owner: nobody
Type: Bug | Status: closed
Component: Utilities | Version: 2.0
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"3b64e2b77570c73a0d7092124fa73439e0fb4305" 3b64e2b7]:
{{{
#!CommitTicketReference repository=""
revision="3b64e2b77570c73a0d7092124fa73439e0fb4305"
Refs #29478 -- Clarified cached_property 2.2 release note.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29478#comment:10>

Django

unread,
Feb 12, 2019, 6:35:41 PM2/12/19
to django-...@googlegroups.com
#29478: cached_property decorator doesn't work with mangled method names
---------------------------------+------------------------------------

Reporter: Thomas Grainger | Owner: nobody
Type: Bug | Status: closed
Component: Utilities | Version: 2.0
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"c3655b152868176359206a7a759ac38ea5e9c047" c3655b1]:
{{{
#!CommitTicketReference repository=""
revision="c3655b152868176359206a7a759ac38ea5e9c047"
[2.2.x] Refs #29478 -- Clarified cached_property 2.2 release note.

Backport of 3b64e2b77570c73a0d7092124fa73439e0fb4305 from master.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29478#comment:11>

Reply all
Reply to author
Forward
0 new messages