Opened 6 months ago

Closed 6 months ago

Last modified 6 months 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

Description

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 Changed 6 months ago by Tim Graham

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 Changed 6 months ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In d1d08d86:

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

comment:3 Changed 6 months ago by Tim Graham <timograham@…>

In 5dc6f77:

Refs #28230 -- Forwardported 1.11.2 release note.

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