From: Raymond Hettinger Date: Tue, 27 Dec 2016 09:06:52 +0000 (-0800) Subject: Issue #29055: Suppress upstream exception for random.choice() X-Git-Tag: v3.6.1rc1~257 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bb2839b680b565f99e463921f3c28fb3c7368096;p=thirdparty%2FPython%2Fcpython.git Issue #29055: Suppress upstream exception for random.choice() --- diff --git a/Lib/random.py b/Lib/random.py index 49b0f149a5a5..ad1c9167b02a 100644 --- a/Lib/random.py +++ b/Lib/random.py @@ -254,7 +254,7 @@ class Random(_random.Random): try: i = self._randbelow(len(seq)) except ValueError: - raise IndexError('Cannot choose from an empty sequence') + raise IndexError('Cannot choose from an empty sequence') from None return seq[i] def shuffle(self, x, random=None): diff --git a/Misc/NEWS b/Misc/NEWS index 6947359cd03b..544c8e593c2e 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -42,6 +42,9 @@ Library - Issue 28923: Remove editor artifacts from Tix.py. +- Issue #29055: Neaten-up empty population error on random.choice() + by suppressing the upstream exception. + - Issue #28871: Fixed a crash when deallocate deep ElementTree. - Issue #19542: Fix bugs in WeakValueDictionary.setdefault() and