Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#31663 closed Bug (fixed)

DecimalField.to_python() raises TypeError on dict values.

Reported by: Sasha Pachev Owned by: Sasha Pachev
Component: Database layer (models, ORM) Version: 3.1
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

A call to DecimalField.to_python() with a dictionary as the value parameter produces TypeError instead of ValidationError. This is a problem, for example, when you try to save a model object, and a decimal field got set to a dictionary by mistake. The TypeError exception that comes back makes it hard to track the problem to the field if the object has a lot of fields.

I am proposing a patch to fix it:

https://github.com/django/django/pull/13023

Change History (3)

comment:1 by Mariusz Felisiak, 4 years ago

Owner: changed from nobody to Sasha Pachev
Status: newassigned
Summary: A call to DecimalField.to_python() with a dictionary as the value parameter produces TypeError instead of ValidationErrorDecimalField.to_python() raises TypeError on dict values.
Triage Stage: UnreviewedAccepted
Type: UncategorizedBug
Version: 3.03.1

comment:2 by GitHub <noreply@…>, 4 years ago

Resolution: fixed
Status: assignedclosed

In 38a21f2d:

Fixed #31663 -- Made DecimalField.to_python() handle non-numeric invalid values.

comment:3 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

In 21adaffb:

[3.1.x] Fixed #31663 -- Made DecimalField.to_python() handle non-numeric invalid values.

Backport of 38a21f2d9ed4f556af934498ec6a242f6a20418a from master

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