Read about our upcoming Code of Conduct on this issue

Commit f57fcde6 authored by Martin von Zweigbergk's avatar Martin von Zweigbergk
Browse files

py3: make random topic name generation consistent across py2/py3

random.choice() (and others based on random.randint()) changed between
py2 and py3 without a way to get the py2 behavior. However,
random.random() did not change, so we can re-implement random.choice()
based on that.
parent 87d3955467b4
......@@ -1005,6 +1005,9 @@ adjectives = [
]
def randomtopicname(ui):
# Re-implement random.choice() in the way it was written in Python 2.
def choice(things):
return things[int(len(things) * random.random())]
if ui.configint("devel", "randomseed"):
random.seed(ui.configint("devel", "randomseed"))
return random.choice(adjectives) + "-" + random.choice(animals)
return choice(adjectives) + "-" + choice(animals)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment