Opened 22 months ago

Closed 21 months ago

Last modified 21 months ago

#34000 closed Bug (fixed)

Fix numberformat.py "string index out of range" when null

Reported by: Jimmy Angelakos Owned by: Jimmy Angelakos
Component: Utilities Version: 4.1
Severity: Normal Keywords:
Cc: Graham Coster Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

When:

if str_number[0] == "-"

encounters a number field that's null when formatting for the admin list_display this causes an

IndexError: string index out of range

I can attach the proposed fix here, or open a pull request on GitHub if you like?

Attachments (2)

4375ad983f2adbfdd091a1e92a847dd108d04c02.patch (931 bytes ) - added by Jimmy Angelakos 22 months ago.
proposed fix patch
c10cec4352d7cfa7c848f2aaf590e1692e1b92ae.diff (1.1 KB ) - added by Jimmy Angelakos 21 months ago.
updated patch

Download all attachments as: .zip

Change History (14)

by Jimmy Angelakos, 22 months ago

proposed fix patch

comment:1 by Claude Paroz, 22 months ago

Needs tests: set
Triage Stage: UnreviewedAccepted

Please provide a pull request, including a test.

comment:2 by Bhuvnesh, 22 months ago

Owner: changed from nobody to Bhuvnesh
Status: newassigned

comment:3 by Jimmy Angelakos, 22 months ago

PR

Regression test added and pull request submitted (attaching as patch).
This is a crashing bug, I wonder if it should be backported?

comment:4 by Jimmy Angelakos, 22 months ago

Needs tests: unset

comment:5 by Bhuvnesh, 22 months ago

Needs tests: set
Owner: Bhuvnesh removed
Status: assignednew

comment:6 by Bhuvnesh, 22 months ago

Needs tests: unset

comment:7 by Graham Coster, 22 months ago

Triage Stage: AcceptedReady for checkin

comment:8 by Graham Coster, 22 months ago

Cc: Graham Coster added

comment:9 by Mariusz Felisiak, 21 months ago

Owner: set to Jimmy Angelakos
Patch needs improvement: set
Status: newassigned
Triage Stage: Ready for checkinAccepted

This is a crashing bug, I wonder if it should be backported?

This a long standing issue (Django < 1.11). Per our backporting policy this means it doesn't qualify for a backport. See Django’s release process for more details.

by Jimmy Angelakos, 21 months ago

updated patch

comment:10 by Mariusz Felisiak, 21 months ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:11 by Mariusz Felisiak <felisiak.mariusz@…>, 21 months ago

Resolution: fixed
Status: assignedclosed

In e911e09:

Fixed #34000 -- Fixed numberformat.format() crash on empty strings.

comment:12 by Mariusz Felisiak <felisiak.mariusz@…>, 21 months ago

In 07ebef56:

Refs #34000 -- Optimized handling None values in numberformat.format().

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