Opened 5 years ago

Closed 5 years ago

Last modified 5 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, 5 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@…>, 5 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@…>, 5 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