Opened 2 years ago

Closed 2 years ago

Last modified 2 years 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 2 years ago.
proposed fix patch
c10cec4352d7cfa7c848f2aaf590e1692e1b92ae.diff (1.1 KB ) - added by Jimmy Angelakos 2 years ago.
updated patch

Download all attachments as: .zip

Change History (14)

by Jimmy Angelakos, 2 years ago

proposed fix patch

comment:1 by Claude Paroz, 2 years ago

Needs tests: set
Triage Stage: UnreviewedAccepted

Please provide a pull request, including a test.

comment:2 by Bhuvnesh, 2 years ago

Owner: changed from nobody to Bhuvnesh
Status: newassigned

comment:3 by Jimmy Angelakos, 2 years 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, 2 years ago

Needs tests: unset

comment:5 by Bhuvnesh, 2 years ago

Needs tests: set
Owner: Bhuvnesh removed
Status: assignednew

comment:6 by Bhuvnesh, 2 years ago

Needs tests: unset

comment:7 by Graham Coster, 2 years ago

Triage Stage: AcceptedReady for checkin

comment:8 by Graham Coster, 2 years ago

Cc: Graham Coster added

comment:9 by Mariusz Felisiak, 2 years 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, 2 years ago

updated patch

comment:10 by Mariusz Felisiak, 2 years ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:11 by Mariusz Felisiak <felisiak.mariusz@…>, 2 years ago

Resolution: fixed
Status: assignedclosed

In e911e09:

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

comment:12 by Mariusz Felisiak <felisiak.mariusz@…>, 2 years ago

In 07ebef56:

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

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