[issue44018] Bug in random.seed
Miguel Brito
report at bugs.python.org
Mon May 3 06:20:29 EDT 2021
Miguel Brito <miguel.mdebrito at gmail.com> added the comment:
The problem is that random seed will do
```
if isinstance(a, str):
a = a.encode()
a += _sha512(a).digest()
a = int.from_bytes(a, 'big')
```
and that will modify the bytearray in place.
>>> a = bytearray("1234", "utf-8")
>>> a += b"digest"
>>> a
bytearray(b'1234digest')
IMHO, seed shouldn't modify the input. Since str, and bytes are immutable that will only happen when passing a bytearray which is not consistent.
----------
nosy: +miguendes
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44018>
_______________________________________
More information about the Python-bugs-list
mailing list