#27154: Minor difference in behavior between CallableFalse/CallableTrue and False/True. --------------------------------------+-------------------- Reporter: tomchristie | Owner: nobody Type: Cleanup/optimization | Status: new Component: contrib.auth | Version: 1.10 Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 1 | UI/UX: 0 --------------------------------------+-------------------- Original raised as a ticket in REST framework: https://github.com/tomchristie/django-rest-framework/issues/4439
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. -- 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/054.c98a0a0546f159abbbb352c49889f1fb%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.