Mercurial > hg-stable
changeset 49592:c217d94cdd9d stable
python-compat: adapt to Python 3.11 BC breakage with `random.sample`
As per https://docs.python.org/3/whatsnew/3.11.html#porting-to-python-3-11:
"The population parameter of `random.sample()` must be a sequence, and
automatic conversion of sets to lists is no longer supported.
Also, if the sample size is larger than the population size,
a `ValueError` is raised"
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Wed, 23 Nov 2022 14:42:11 +0100 |
parents | c4874ebe8644 |
children | c6f0bcb7bc57 |
files | mercurial/setdiscovery.py |
diffstat | 1 files changed, 1 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/setdiscovery.py Tue Nov 22 11:55:26 2022 -0500 +++ b/mercurial/setdiscovery.py Wed Nov 23 14:42:11 2022 +0100 @@ -99,9 +99,9 @@ """ if len(sample) <= desiredlen: return sample + sample = list(sample) if randomize: return set(random.sample(sample, desiredlen)) - sample = list(sample) sample.sort() return set(sample[:desiredlen])