Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#28230 closed Cleanup/optimization (fixed)

Allow DjangoJsonEncoder to serialize CallableBool

Reported by: vinay karanam Owned by: nobody
Component: Core (Serialization) Version: 1.11
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Passing values derived using user.is_authenticated or user.is_anonymous to JsonResponse causes it to crash.

Example condition:

is_member = user.is_authenticated and user.<custom_method>

If user is authenticated, value of is_member depends on the return value of custom_method.
If user is anonymous, CallableFalse is passed to JsonResponse and raises TypeError.

Change History (3)

comment:1 by Tim Graham, 7 years ago

Component: UncategorizedCore (Serialization)
Has patch: set
Summary: CallableBool is not JSON serializableAllow DjangoJsonEncoder to serialize CallableBool
Triage Stage: UnreviewedReady for checkin
Type: UncategorizedCleanup/optimization

The PR looks good pending a few cosmetic updates.

comment:2 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: newclosed

In d1d08d86:

[1.11.x] Fixed #28230 -- Allowed DjangoJsonEncoder to serialize CallableBool.

comment:3 by Tim Graham <timograham@…>, 7 years ago

In 5dc6f77:

Refs #28230 -- Forwardported 1.11.2 release note.

Note: See TracTickets for help on using tickets.
Back to Top