Opened 12 years ago
Closed 12 years ago
#19777 closed Bug (wontfix)
Casting a SimpleLazyObject to an int fails
Reported by: | Matt Robenolt | Owned by: | nobody |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | Normal | Keywords: | functional simplelazyobject |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Should be pretty self explanatory. We noticed the bug when passing request.user
into a filter like:
Model.objects.filter(user=request.user)
Since Django is attempting to coerce the object to an int, it fails on the SimpleLazyObject yielding:
TypeError: int() argument must be a string or a number, not 'SimpleLazyObject'
The error can be reproduced simple by doing:
class Foo(object): __int__ = lambda self: 1 int(SimpleLazyObject(Foo)))
See https://github.com/django/django/pull/706 for a patch.
Note:
See TracTickets
for help on using tickets.
Closing after IRC discussion: