Opened 7 years ago

Closed 7 years ago

#11783 closed (fixed)

django.contrib.humanize.templatetags.ordinal throws TypeError for NoneType

Reported by: realpolitik Owned by: nobody
Component: Contrib apps Version: 1.1
Severity: Keywords: contrib, humanize, ordinal, ValueError
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The short summary probably covered everything. ordinal(value) catches ValueError but not TypeError.

Error Message: "Exception Value: int() argument must be a string or a number, not 'NoneType'"

Attachments (2)

humanize_ordinal_TypeError.diff (562 bytes) - added by realpolitik 7 years ago.
humanize ordinal TypeError? fix (updated)
humanize_ordinal_TypeError_with_tests.diff (1.3 KB) - added by punteney 7 years ago.
Updated diff with test case

Download all attachments as: .zip

Change History (8)

comment:1 Changed 7 years ago by Alex Gaynor

Needs documentation: unset
Needs tests: set
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

comment:2 Changed 7 years ago by Chris Beaven

Patch needs improvement: set

That should be:

    except (TypeError, ValueError):

Changed 7 years ago by realpolitik

humanize ordinal TypeError? fix (updated)

comment:3 Changed 7 years ago by realpolitik

Patch needs improvement: unset

Changed 7 years ago by punteney

Updated diff with test case

comment:4 Changed 7 years ago by punteney

Needs tests: unset

Added a test to the patch to check for the None TypeError

comment:5 Changed 7 years ago by Chris Beaven

Triage Stage: AcceptedReady for checkin

comment:6 Changed 7 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

(In [12199]) Fixed #11783 -- ordinal template tag now catches TypeError. Thanks, realpolitik and punteney

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