# HG changeset patch # User Raphaël Gomès # Date 2022-11-23 13:42:11 # Node ID c217d94cdd9d5efae57836b24ef351b88a1415e3 # Parent c4874ebe8644b03a19c35136c3fa06256feada41 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" diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py --- a/mercurial/setdiscovery.py +++ b/mercurial/setdiscovery.py @@ -99,9 +99,9 @@ def _limitsample(sample, desiredlen, ran """ 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])