Skip to content

Commit 99ec6b3

Browse files
committed
gh-158486: Fix PowerSort mask calculation for very large lists
1 parent 77c0675 commit 99ec6b3

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix the PowerSort mask calculation in :meth:`list.sort` for very large
2+
lists.

‎Objects/listobject.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2263,7 +2263,7 @@ merge_init(MergeState *ms, Py_ssize_t list_size, int has_keyfunc,
22632263
while (list_size >> ms->mr_e >= MAX_MINRUN) {
22642264
++ms->mr_e;
22652265
}
2266-
ms->mr_mask = (1 << ms->mr_e) - 1;
2266+
ms->mr_mask = ((Py_ssize_t)1 << ms->mr_e) - 1;
22672267
ms->mr_current = 0;
22682268
}
22692269

0 commit comments

Comments
 (0)