[Django] #37096: test_invalid_choice_db_option fails on Python 3.14.5+

20 views
Skip to first unread message

Django

unread,
May 12, 2026, 1:13:35 AMMay 12
to django-...@googlegroups.com
#37096: test_invalid_choice_db_option fails on Python 3.14.5+
-------------------------------------+-------------------------------------
Reporter: Kasey | Type: Bug
Status: new | Component: Core
| (Management commands)
Version: dev | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
On Python 3.14.5+,
`admin_scripts.tests.CommandDBOptionChoiceTests.test_invalid_choice_db_option`
fails with:

{{{
AssertionError: "Error: argument --database: invalid choice: 'deflaut',
maybe you meant 'default'\? \(choose from default, other\)" does not match
"Error: argument --database: invalid choice: 'deflaut', maybe you meant
'default'? (choose from 'default', 'other')"
}}}

== Cause ==

CPython 3.14.5 restored quoting of choice values in argparse's "invalid
choice" error messages via [https://github.com/python/cpython/pull/149385
cpython#149385] (3.14 backport of
[https://github.com/python/cpython/pull/130751 cpython#130751], tracked in
[https://github.com/python/cpython/issues/130750 cpython#130750]). The
`choices` formatter changed from:

{{{#!python
'choices': ', '.join(map(str, action.choices)) # 3.14.0–3.14.4
}}}

to:

{{{#!python
'choices': ', '.join(repr(str(choice)) for choice in action.choices) #
3.14.5+
}}}

so the message goes from `(choose from default, other)` to `(choose from
'default', 'other')`.

The `PY314` branch of the test (added in commit
[https://github.com/django/django/commit/b1a65eac7c b1a65eac7c], fixing
#36321) expected the unquoted form. The pre-3.14 branch already handles
both forms via `'?default'?, '?other'?`; aligning the `PY314` branch with
the same pattern fixes the test on all Python 3.14.x releases.

== Scope ==

`main` only. `stable/6.0.x` and `stable/5.2.x` are unaffected — neither
branch enables `suggest_on_error` (added in #36321 on `main`), and both
already use the flexible `'?default'?, '?other'?` pattern.

== Patch ==

Patch ready (one-line test regex fix). PR link will follow in a comment
once the ticket is accepted.
--
Ticket URL: <https://code.djangoproject.com/ticket/37096>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 12, 2026, 1:13:52 AMMay 12
to django-...@googlegroups.com
#37096: test_invalid_choice_db_option fails on Python 3.14.5+
-------------------------------------+-------------------------------------
Reporter: Kasey | Owner: Kasey
Type: Bug | Status: assigned
Component: Core (Management | Version: dev
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Kasey):

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

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

Django

unread,
May 12, 2026, 7:59:11 AMMay 12
to django-...@googlegroups.com
#37096: test_invalid_choice_db_option fails on Python 3.14.5+
-------------------------------------+-------------------------------------
Reporter: Kasey | Owner: Kasey
Type: Bug | Status: assigned
Component: Core (Management | Version: dev
commands) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* severity: Normal => Release blocker
* stage: Unreviewed => Accepted

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

Django

unread,
May 12, 2026, 11:30:11 AMMay 12
to django-...@googlegroups.com
#37096: test_invalid_choice_db_option fails on Python 3.14.5+
-------------------------------------+-------------------------------------
Reporter: Kasey | Owner: Kasey
Type: Bug | Status: assigned
Component: Core (Management | Version: dev
commands) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Kasey):

* has_patch: 0 => 1

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

Django

unread,
May 12, 2026, 11:45:15 AMMay 12
to django-...@googlegroups.com
#37096: test_invalid_choice_db_option fails on Python 3.14.5+
-------------------------------------+-------------------------------------
Reporter: Kasey | Owner: Kasey
Type: Bug | Status: assigned
Component: Core (Management | Version: dev
commands) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Kasey):

https://github.com/django/django/pull/21275
--
Ticket URL: <https://code.djangoproject.com/ticket/37096#comment:4>

Django

unread,
May 12, 2026, 3:16:53 PMMay 12
to django-...@googlegroups.com
#37096: test_invalid_choice_db_option fails on Python 3.14.5+
-------------------------------------+-------------------------------------
Reporter: Kasey | Owner: Kasey
Type: Bug | Status: closed
Component: Core (Management | Version: dev
commands) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls <jacobtylerwalls@…>):

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

Comment:

In [changeset:"ed13a58bf63df94508c8a0fe779da0b6a2bc26bb" ed13a58]:
{{{#!CommitTicketReference repository=""
revision="ed13a58bf63df94508c8a0fe779da0b6a2bc26bb"
Fixed #37096 -- Fixed test_invalid_choice_db_option on Python 3.14.5+.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/37096#comment:5>

Django

unread,
May 12, 2026, 3:17:19 PMMay 12
to django-...@googlegroups.com
#37096: test_invalid_choice_db_option fails on Python 3.14.5+
-------------------------------------+-------------------------------------
Reporter: Kasey | Owner: Kasey
Type: Bug | Status: closed
Component: Core (Management | Version: dev
commands) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/37096#comment:6>
Reply all
Reply to author
Forward
0 new messages