Opened 17 months ago

Closed 5 days ago

Last modified 5 days ago

#36104 closed Bug (fixed)

forms.Media shouldn't expect media objects only

Reported by: Matthias Kestenholz Owned by: Jacob Walls
Component: Forms Version: dev
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

While thinking about https://forum.djangoproject.com/t/rejuvenating-vs-deprecating-form-media/21285 I have noticed that the forms.Media.__add__ method assumes that media objects are only ever added to each other. That doesn't necessarily have to be the case.

I propose returning NotImplemented when the RHS isn't a Media instance but something else.

All tests pass locally.

(It has nothing to do with https://code.djangoproject.com/ticket/35648 specifically but the same discussion probably applies.)

Change History (9)

comment:1 by Matthias Kestenholz, 17 months ago

comment:2 by Natalia Bidart, 17 months ago

Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization
Version: 5.1dev

Accepting, this is somewhat similar in concept to #35648.

Last edited 17 months ago by Natalia Bidart (previous) (diff)

comment:3 by Raphael Gaschignard, 16 months ago

Patch needs improvement: set

comment:4 by Tim Schilling, 6 days ago

Patch needs improvement: unset

This PR was ready for another review, but Trac wasn't updated.

comment:5 by Jacob Walls, 5 days ago

Patch needs improvement: set
Type: Cleanup/optimizationBug

The additional flexibility might be a cleanup, but not returning NotImplemented for arbitrary types is a bug IMO. Left minor questions on the PR.

comment:6 by Jacob Walls, 5 days ago

Owner: changed from Matthias Kestenholz to Jacob Walls
Patch needs improvement: unset

comment:7 by Jacob Walls, 5 days ago

Triage Stage: AcceptedReady for checkin

Clifford and Hasan approved on GitHub.

comment:8 by Jacob Walls <jacobtylerwalls@…>, 5 days ago

Resolution: fixed
Status: assignedclosed

In a2f8a4a:

Fixed #36104 -- Returned NotImplemented in Media.add for non-Media RHS.

comment:9 by Jacob Walls <jacobtylerwalls@…>, 5 days ago

In 83e2a3b:

[6.1.x] Fixed #36104 -- Returned NotImplemented in Media.add for non-Media RHS.

Backport of a2f8a4a6f9ac094edde937e56a3ecbd112ee448c from main.

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