[New-bugs-announce] [issue31478] assertion failure in random.seed() in case the seed argument has a bad __abs__() method
Oren Milman
report at bugs.python.org
Thu Sep 14 16:33:46 EDT 2017
New submission from Oren Milman:
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)
----------
components: Extension Modules
messages: 302208
nosy: Oren Milman
priority: normal
severity: normal
status: open
title: assertion failure in random.seed() in case the seed argument has a bad __abs__() method
type: crash
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31478>
_______________________________________
More information about the New-bugs-announce
mailing list