]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #29055: Suppress upstream exception for random.choice()
authorRaymond Hettinger <python@rcn.com>
Tue, 27 Dec 2016 09:06:52 +0000 (01:06 -0800)
committerRaymond Hettinger <python@rcn.com>
Tue, 27 Dec 2016 09:06:52 +0000 (01:06 -0800)
Lib/random.py
Misc/NEWS

index 49b0f149a5a5001a42045d29c01aea7ed7514798..ad1c9167b02a65c6783260848e2713c8fc0b9f62 100644 (file)
@@ -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):
index 6947359cd03b0f3ae2d25ff20106a8cf52be28cd..544c8e593c2edcc676cf4d88abb454458d895fd9 100644 (file)
--- 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