#37096 closed Bug (fixed)
test_invalid_choice_db_option fails on Python 3.14.5+
| Reported by: | Kasey | Owned by: | Kasey |
|---|---|---|---|
| Component: | Core (Management commands) | Version: | dev |
| Severity: | Release blocker | Keywords: | |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
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 cpython#149385 (3.14 backport of cpython#130751, tracked in cpython#130750). The choices formatter changed from:
'choices': ', '.join(map(str, action.choices)) # 3.14.0–3.14.4
to:
'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 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.
Change History (6)
comment:1 by , 19 hours ago
| Owner: | set to |
|---|---|
| Status: | new → assigned |
comment:2 by , 12 hours ago
| Severity: | Normal → Release blocker |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
comment:3 by , 8 hours ago
| Has patch: | set |
|---|
comment:4 by , 8 hours ago
comment:6 by , 5 hours ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
https://github.com/django/django/pull/21275