[Django] #34000: Fix numberformat.py "string index out of range" when null

3 views
Skip to first unread message

Django

unread,
Sep 9, 2022, 6:44:49 PM9/9/22
to django-...@googlegroups.com
#34000: Fix numberformat.py "string index out of range" when null
-------------------------------------------+------------------------
Reporter: Jimmy Angelakos | Owner: nobody
Type: Bug | Status: new
Component: Utilities | Version: 4.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------------+------------------------
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?

--
Ticket URL: <https://code.djangoproject.com/ticket/34000>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 9, 2022, 6:45:07 PM9/9/22
to django-...@googlegroups.com
#34000: Fix numberformat.py "string index out of range" when null
---------------------------------+--------------------------------------

Reporter: Jimmy Angelakos | Owner: nobody
Type: Bug | Status: new
Component: Utilities | Version: 4.1
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by Jimmy Angelakos):

* Attachment "4375ad983f2adbfdd091a1e92a847dd108d04c02.patch" added.

proposed fix patch

Django

unread,
Sep 10, 2022, 5:25:26 AM9/10/22
to django-...@googlegroups.com
#34000: Fix numberformat.py "string index out of range" when null
---------------------------------+------------------------------------
Reporter: Jimmy Angelakos | Owner: nobody
Type: Bug | Status: new
Component: Utilities | Version: 4.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Claude Paroz):

* needs_tests: 0 => 1
* stage: Unreviewed => Accepted


Comment:

Please provide a pull request, including a test.

--
Ticket URL: <https://code.djangoproject.com/ticket/34000#comment:1>

Django

unread,
Sep 10, 2022, 9:21:48 AM9/10/22
to django-...@googlegroups.com
#34000: Fix numberformat.py "string index out of range" when null
---------------------------------+------------------------------------
Reporter: Jimmy Angelakos | Owner: Bhuvnesh
Type: Bug | Status: assigned

Component: Utilities | Version: 4.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Bhuvnesh):

* owner: nobody => Bhuvnesh
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/34000#comment:2>

Django

unread,
Sep 10, 2022, 9:28:43 AM9/10/22
to django-...@googlegroups.com
#34000: Fix numberformat.py "string index out of range" when null
---------------------------------+------------------------------------
Reporter: Jimmy Angelakos | Owner: Bhuvnesh
Type: Bug | Status: assigned
Component: Utilities | Version: 4.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Jimmy Angelakos):

* Attachment "c10cec4352d7cfa7c848f2aaf590e1692e1b92ae.diff" added.

PR diff

Django

unread,
Sep 10, 2022, 9:28:55 AM9/10/22
to django-...@googlegroups.com
#34000: Fix numberformat.py "string index out of range" when null
---------------------------------+------------------------------------
Reporter: Jimmy Angelakos | Owner: Bhuvnesh
Type: Bug | Status: assigned
Component: Utilities | Version: 4.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------

Comment (by Jimmy Angelakos):

[https://github.com/django/django/pull/16046 PR]

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

--
Ticket URL: <https://code.djangoproject.com/ticket/34000#comment:3>

Django

unread,
Sep 10, 2022, 9:29:19 AM9/10/22
to django-...@googlegroups.com
#34000: Fix numberformat.py "string index out of range" when null
---------------------------------+------------------------------------
Reporter: Jimmy Angelakos | Owner: Bhuvnesh
Type: Bug | Status: assigned
Component: Utilities | Version: 4.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Jimmy Angelakos):

* needs_tests: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/34000#comment:4>

Django

unread,
Sep 10, 2022, 9:30:34 AM9/10/22
to django-...@googlegroups.com
#34000: Fix numberformat.py "string index out of range" when null
---------------------------------+------------------------------------
Reporter: Jimmy Angelakos | Owner: (none)
Type: Bug | Status: new

Component: Utilities | Version: 4.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Bhuvnesh):

* owner: Bhuvnesh => (none)
* status: assigned => new


* needs_tests: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/34000#comment:5>

Django

unread,
Sep 10, 2022, 9:31:22 AM9/10/22
to django-...@googlegroups.com
#34000: Fix numberformat.py "string index out of range" when null
---------------------------------+------------------------------------
Reporter: Jimmy Angelakos | Owner: (none)
Type: Bug | Status: new
Component: Utilities | Version: 4.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Bhuvnesh):

* needs_tests: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/34000#comment:6>

Django

unread,
Sep 10, 2022, 10:52:09 PM9/10/22
to django-...@googlegroups.com
#34000: Fix numberformat.py "string index out of range" when null
-------------------------------------+-------------------------------------

Reporter: Jimmy Angelakos | Owner: (none)
Type: Bug | Status: new
Component: Utilities | Version: 4.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by grumBit):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/34000#comment:7>

Django

unread,
Sep 10, 2022, 10:54:35 PM9/10/22
to django-...@googlegroups.com
#34000: Fix numberformat.py "string index out of range" when null
-------------------------------------+-------------------------------------
Reporter: Jimmy Angelakos | Owner: (none)
Type: Bug | Status: new
Component: Utilities | Version: 4.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Graham Coster):

* cc: Graham Coster (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/34000#comment:8>

Django

unread,
Sep 11, 2022, 11:32:11 PM9/11/22
to django-...@googlegroups.com
#34000: Fix numberformat.py "string index out of range" when null
-------------------------------------+-------------------------------------
Reporter: Jimmy Angelakos | Owner: Jimmy
| Angelakos
Type: Bug | Status: assigned

Component: Utilities | Version: 4.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* owner: (none) => Jimmy Angelakos
* needs_better_patch: 0 => 1


* status: new => assigned

* stage: Ready for checkin => Accepted


Comment:

> 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
[https://docs.djangoproject.com/en/stable/internals/release-process/
Django’s release process] for more details.

--
Ticket URL: <https://code.djangoproject.com/ticket/34000#comment:9>

Django

unread,
Sep 12, 2022, 5:56:05 AM9/12/22
to django-...@googlegroups.com
#34000: Fix numberformat.py "string index out of range" when null
-------------------------------------+-------------------------------------
Reporter: Jimmy Angelakos | Owner: Jimmy
| Angelakos
Type: Bug | Status: assigned
Component: Utilities | Version: 4.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jimmy Angelakos):

* Attachment "c10cec4352d7cfa7c848f2aaf590e1692e1b92ae.diff" added.

updated patch

Django

unread,
Sep 12, 2022, 5:56:05 AM9/12/22
to django-...@googlegroups.com
#34000: Fix numberformat.py "string index out of range" when null
-------------------------------------+-------------------------------------
Reporter: Jimmy Angelakos | Owner: Jimmy
| Angelakos
Type: Bug | Status: assigned
Component: Utilities | Version: 4.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jimmy Angelakos):

* Attachment "c10cec4352d7cfa7c848f2aaf590e1692e1b92ae.diff" removed.

PR diff

Django

unread,
Sep 12, 2022, 7:03:54 AM9/12/22
to django-...@googlegroups.com
#34000: Fix numberformat.py "string index out of range" when null
-------------------------------------+-------------------------------------
Reporter: Jimmy Angelakos | Owner: Jimmy
| Angelakos
Type: Bug | Status: assigned
Component: Utilities | Version: 4.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 1 => 0


* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/34000#comment:10>

Django

unread,
Sep 12, 2022, 7:31:03 AM9/12/22
to django-...@googlegroups.com
#34000: Fix numberformat.py "string index out of range" when null
-------------------------------------+-------------------------------------
Reporter: Jimmy Angelakos | Owner: Jimmy
| Angelakos
Type: Bug | Status: closed
Component: Utilities | Version: 4.1
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"07ebef566f751e172e266165071081c7614e2d33" 07ebef56]:
{{{
#!CommitTicketReference repository=""
revision="07ebef566f751e172e266165071081c7614e2d33"
Refs #34000 -- Optimized handling None values in numberformat.format().
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34000#comment:12>

Django

unread,
Sep 12, 2022, 7:31:03 AM9/12/22
to django-...@googlegroups.com
#34000: Fix numberformat.py "string index out of range" when null
-------------------------------------+-------------------------------------
Reporter: Jimmy Angelakos | Owner: Jimmy
| Angelakos
Type: Bug | Status: closed
Component: Utilities | Version: 4.1
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"e911e0996f1096cc23ef03b1ca70da7499dd8f2f" e911e09]:
{{{
#!CommitTicketReference repository=""
revision="e911e0996f1096cc23ef03b1ca70da7499dd8f2f"
Fixed #34000 -- Fixed numberformat.format() crash on empty strings.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34000#comment:11>

Reply all
Reply to author
Forward
0 new messages