Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue29055

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:random.choice on empty sequence should hide previous exception [patch]
Type:behaviorStage:
Components:Library (Lib)Versions:Python 3.7, Python 3.6
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To: rhettingerNosy List: josh.r, mark.dickinson, python-dev, rhettinger, then0rTh
Priority:normalKeywords:patch

Created on2016-12-23 15:56 bythen0rTh, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
random_choice_errmsg.patchthen0rTh,2016-12-23 15:56patch for random.pyreview
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)*(Python triager)Date: 2016-12-23 16:47
Seems reasonable to me.
msg284074 -(view)Author: Roundup Robot (python-dev)(Python triager)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)*(Python committer)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
DateUserActionArgs
2022-04-11 14:58:41adminsetgithub: 73241
2016-12-27 09:09:33rhettingersetstatus: open -> closed
resolution: fixed
messages: +msg284075

versions: + Python 3.6
2016-12-27 09:07:23python-devsetnosy: +python-dev
messages: +msg284074
2016-12-27 08:55:50rhettingersetassignee:rhettinger
2016-12-23 16:47:03josh.rsetnosy: +josh.r
messages: +msg283886
2016-12-23 15:56:57then0rThcreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp