Issue29055
Created on 2016-12-23 15:56 by then0rTh, last changed 2016-12-27 09:09 by rhettinger. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| random_choice_errmsg.patch | then0rTh, 2016-12-23 15:56 | patch for random.py | review | |
| Messages (4) | |||
|---|---|---|---|
| msg283884 - (view) | Author: (then0rTh) | Date: 2016-12-23 15:56 | |
Passing empty sequence to random.choice function leads to: Traceback (most recent call last): ... ValueError: number of bits must be greater than zero During handling of the above exception, another exception occurred: Traceback (most recent call last): ... IndexError: Cannot choose from an empty sequence * the ValueError doesn't add any useful information, only bloats stderr * the "During handling" line indicates that something went wrong inside random.py This patch uses `raise x from None` to hide the ValueError, resulting in much cleaner output. -Tested on Python 3.7.0a0 |
|||
| msg283886 - (view) | Author: Josh Rosenberg (josh.r) * | Date: 2016-12-23 16:47 | |
Seems reasonable to me. |
|||
| msg284074 - (view) | Author: Roundup Robot (python-dev) | Date: 2016-12-27 09:07 | |
New changeset 0001ae913759 by Raymond Hettinger in branch '3.6': Issue #29055: Suppress upstream exception for random.choice() https://hg.python.org/cpython/rev/0001ae913759 |
|||
| msg284075 - (view) | Author: Raymond Hettinger (rhettinger) * | Date: 2016-12-27 09:09 | |
Thanks for the patch. Please submit a contributor agreement for future work. We would like to have it for all patches (though this one was so tiny it isn't strictly required). |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2016-12-27 09:09:33 | rhettinger | set | status: open -> closed resolution: fixed messages: + msg284075 versions: + Python 3.6 |
| 2016-12-27 09:07:23 | python-dev | set | nosy:
+ python-dev messages: + msg284074 |
| 2016-12-27 08:55:50 | rhettinger | set | assignee: rhettinger |
| 2016-12-23 16:47:03 | josh.r | set | nosy:
+ josh.r messages: + msg283886 |
| 2016-12-23 15:56:57 | then0rTh | create | |