Message302208
| Author |
Oren Milman |
| Recipients |
Oren Milman |
| Date |
2017-09-14.20:33:46 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1505421226.31.0.0993536255685.issue31478@psf.upfronthosting.co.za> |
| In-reply-to |
|
| Content |
The following code causes an assertion failure:
class BadInt(int):
def __abs__(self):
return None
import random
random.seed(BadInt())
this is because random_seed() (in Modules/_randommodule.c) assumes that
PyNumber_Absolute() returned an int, and so it passes it to _PyLong_NumBits(),
which asserts it received an int.
what should we do in such a case?
should we raise an exception? (the docs don't mention abs() in case the seed is
an int - https://docs.python.org/3.7/library/random.html#random.seed) |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2017-09-14 20:33:46 | Oren Milman | set | recipients:
+ Oren Milman |
| 2017-09-14 20:33:46 | Oren Milman | set | messageid: <1505421226.31.0.0993536255685.issue31478@psf.upfronthosting.co.za> |
| 2017-09-14 20:33:46 | Oren Milman | link | issue31478 messages |
| 2017-09-14 20:33:46 | Oren Milman | create | |
|