https://github.com/python/cpython/commit/cc30d60cdad391460a210bff79a0de8e0ae519ef commit: cc30d60cdad391460a210bff79a0de8e0ae519ef branch: 3.15 author: Miss Islington (bot) <[email protected]> committer: vstinner <[email protected]> date: 2026-10-09T21:49:00+02:00 summary:
[3.15] gh-158486: Fix PowerSort mask calculation for very large lists (GH-158487) (#158869) gh-158486: Fix PowerSort mask calculation for very large lists (GH-158487) (cherry picked from commit 14641b0badff11e2f90a4e8839287d8c2872bad8) Co-authored-by: Neel Somani <[email protected]> files: A Misc/NEWS.d/next/Core_and_Builtins/2026-09-30-01-30-58.gh-issue-158486.cqmMwv.rst M Objects/listobject.c diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-09-30-01-30-58.gh-issue-158486.cqmMwv.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-09-30-01-30-58.gh-issue-158486.cqmMwv.rst new file mode 100644 index 00000000000000..6ef73833fcdb76 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-09-30-01-30-58.gh-issue-158486.cqmMwv.rst @@ -0,0 +1,2 @@ +Fix the PowerSort mask calculation in :meth:`list.sort` for very large +lists. diff --git a/Objects/listobject.c b/Objects/listobject.c index 8a9c9bda68269b..9f059ec875d7ea 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -2263,7 +2263,7 @@ merge_init(MergeState *ms, Py_ssize_t list_size, int has_keyfunc, while (list_size >> ms->mr_e >= MAX_MINRUN) { ++ms->mr_e; } - ms->mr_mask = (1 << ms->mr_e) - 1; + ms->mr_mask = ((Py_ssize_t)1 << ms->mr_e) - 1; ms->mr_current = 0; } _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
