Something that may confuse users calling `.is_authenticated`...
There's a slight difference in behavior between how the
CallableFalse/CallableTrue instances behave compare to how False/True
behave.
The Python boolean type happens to support the bitwise OR operator, and
its behavior in this case is exactly equivalent to the `or` operator. Eg.
`False | True` returns `True`
The backwards compat CallableFalse/CallableTrue instances do not support
this usage, and will fail with eg. `TypeError: unsupported operand type(s)
for |: 'instance' and 'bool'`
Their behavior is reasonable enough, and the user should really be using
the boolean `or` operator, but we might introduce slightly less friction
(ie don't raise a slightly opaque error message to the user) if we simply
support and allow the bitwise operator in the same way as the boolean
equivalents.
I'm probably a +0 on resolving this, as think it'd save a few folks a bit
of head banging. Certainly wouldn't dispute a `wontfix` categorization.
Tip for easy pickings folks: Should be resolvable by including an `__or__`
method on the CallableFalse/CallableTrue classes.
--
Ticket URL: <https://code.djangoproject.com/ticket/27154>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* stage: Unreviewed => Accepted
* needs_tests: => 0
* needs_docs: => 0
Comment:
The change seems simple enough and I don't see any drawbacks to adding it.
If we can make our users' lives easier, I'm +1 on it.
If anyone is interested in tackling this, the
`CallableFalse`/`CallableTrue` classes are defined in
`django/utils/deprecation.py`.
Once the change is made, I think we should also discuss backporting it.
Thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/27154#comment:1>
* severity: Normal => Release blocker
Comment:
The implementation can follow commit
54afa960d1ee8c63635225a0f0a2489971b5aab5.
--
Ticket URL: <https://code.djangoproject.com/ticket/27154#comment:2>
* status: new => assigned
* owner: nobody => alexyer
--
Ticket URL: <https://code.djangoproject.com/ticket/27154#comment:3>
Comment (by alexyer):
Here is the [https://github.com/django/django/pull/7190 PR]. Thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/27154#comment:4>
* has_patch: 0 => 1
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/27154#comment:5>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"b7fb608142a0be568bc5dce952de5e6aefc2488c" b7fb6081]:
{{{
#!CommitTicketReference repository=""
revision="b7fb608142a0be568bc5dce952de5e6aefc2488c"
Fixed #27154 -- Allowed comparing CallableBool with bitwise or.
Thanks Tim for the review.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27154#comment:6>
Comment (by Tim Graham <timograham@…>):
In [changeset:"7c57f5cf8cd10b69d0c76ba97ab048ccc2917c55" 7c57f5c]:
{{{
#!CommitTicketReference repository=""
revision="7c57f5cf8cd10b69d0c76ba97ab048ccc2917c55"
[1.10.x] Fixed #27154 -- Allowed comparing CallableBool with bitwise or.
Thanks Tim for the review.
Backport of b7fb608142a0be568bc5dce952de5e6aefc2488c from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27154#comment:7>