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.
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).
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: