This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Serge Anuchin
Recipients Serge Anuchin, mark.dickinson, rhettinger
Date 2015-07-01.16:06:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1435766790.47.0.448977546687.issue24546@psf.upfronthosting.co.za>
In-reply-to
Content
It seems there is minor bug in random.choice.

I've got traceback from my server with IndexError from random.choice, but sequence wasn't empty (seq value was: u'\u0411\u0413\u0414\u0416\u0418\u041b\u0426\u042b\u042d\
u042e\u042f\u0410\u0412\u0415\u041a\u041c\u0420\u0422\
u042312456789')

Maybe I mistaken, but only explanation that I have for this exception is rounding by int() of random value that was very close to 1.

TL;RD:
>>> int(0.99999999999999995)
1
>>> seq = 'test'
>>> seq[int(0.99999999999999995 * len(seq))] # logic from random.choice
IndexError: string index out of range

Is it plausible explanation of exception or I'am wrong?
History
Date User Action Args
2015-07-01 16:06:30Serge Anuchinsetrecipients: + Serge Anuchin, rhettinger, mark.dickinson
2015-07-01 16:06:30Serge Anuchinsetmessageid: <1435766790.47.0.448977546687.issue24546@psf.upfronthosting.co.za>
2015-07-01 16:06:30Serge Anuchinlinkissue24546 messages
2015-07-01 16:06:29Serge Anuchincreate