
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2016-12-23 15:56 bythen0rTh, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.
| 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 zeroDuring 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.pyThis 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 changeset0001ae913759 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 |
| 2022-04-11 14:58:41 | admin | set | github: 73241 |
| 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 | |