Issue #29055: Suppress upstream exception for random.choice()

This commit is contained in:
Raymond Hettinger 2016-12-27 01:06:52 -08:00
parent 246cbf23fa
commit bb2839b680
2 changed files with 4 additions and 1 deletions

View File

@ -254,7 +254,7 @@ class Random(_random.Random):
try: try:
i = self._randbelow(len(seq)) i = self._randbelow(len(seq))
except ValueError: except ValueError:
raise IndexError('Cannot choose from an empty sequence') raise IndexError('Cannot choose from an empty sequence') from None
return seq[i] return seq[i]
def shuffle(self, x, random=None): def shuffle(self, x, random=None):

View File

@ -42,6 +42,9 @@ Library
- Issue 28923: Remove editor artifacts from Tix.py. - 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 #28871: Fixed a crash when deallocate deep ElementTree.
- Issue #19542: Fix bugs in WeakValueDictionary.setdefault() and - Issue #19542: Fix bugs in WeakValueDictionary.setdefault() and