Is this mistake in utils.functional?

13 views
Skip to first unread message

Akira Furude

unread,
Feb 6, 2020, 12:39:47 PM2/6/20
to Django users
Currently I'm working on my website, and has debugging it for a while.
Using breakpoint() function I found bug/mistake/missed error in django/utils/functional.py cached_property.__get__(), line 48.
That line contains this: res = instance.__dict__[self.name] = self.func(instance).
May be I don't understand a lot in Python, but I think between instance.__dict__[self.name] and self.func(instance) should be check for equality (==) statement.
That version also proving Python interpreter itself, if you type in terminal this: print(instance.__dict__[self.name] = self.func(instance)).
Has attached the screenshot to proof the error.
321.png

Tim Graham

unread,
Feb 7, 2020, 12:26:50 AM2/7/20
to Django users
The code is equivalent to:

res = self.func(instance)
instance.__dict__['self.name'] = self.func(instance)

(except that self.func(instance) isn't called twice like it would be in this version)
Reply all
Reply to author
Forward
0 new messages