[Python-checkins] cpython (3.6): Issue #29055: Suppress upstream exception for random.choice()
raymond.hettinger
python-checkins at python.org
Tue Dec 27 04:07:20 EST 2016
https://hg.python.org/cpython/rev/0001ae913759
changeset: 105834:0001ae913759
branch: 3.6
parent: 105831:a48cc85e5706
user: Raymond Hettinger <python at rcn.com>
date: Tue Dec 27 01:06:52 2016 -0800
summary:
Issue #29055: Suppress upstream exception for random.choice()
files:
Lib/random.py | 2 +-
Misc/NEWS | 3 +++
2 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/Lib/random.py b/Lib/random.py
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -254,7 +254,7 @@
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
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -42,6 +42,9 @@
- 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
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list