[issue44018] Bug in random.seed

2021-05-03 Thread Eugene Rossokha


New submission from Eugene Rossokha :

https://github.com/python/cpython/blob/master/Lib/random.py#L157
If bytearray is passed as a seed, the function will change it.
It either has to be documented, or the implementation should change.

--
components: Library (Lib)
messages: 392782
nosy: arjaz
priority: normal
severity: normal
status: open
title: Bug in random.seed
versions: Python 3.9

___
Python tracker 
<https://bugs.python.org/issue44018>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44018] Bug in random.seed

2021-05-03 Thread Eugene Rossokha


Eugene Rossokha  added the comment:

I find the following behaviour very confusing:

>>> import random
>>> a = bytearray("1234", "utf-8")
>>> b = bytearray("1234", "utf-8")
>>> a == b
True
>>> random.seed(a)
>>> a == b
False
>>> a
bytearray(b'1234\xd4\x04U\x9f`.\xabo\xd6\x02\xacv\x80\xda\xcb\xfa\xad\xd1603^\x95\x1f\tz\xf3\x90\x0e\x9d\xe1v\xb6\xdb(Q/.\x00\x0b\x9d\x04\xfb\xa5\x13>\x8b\x1cn\x8d\xf5\x9d\xb3\xa8\xab\x9d`\xbeK\x97\xcc\x9e\x81\xdb')
>>> b
bytearray(b'1234')

The function doesn't document it will change the input argument

--

___
Python tracker 
<https://bugs.python.org/issue44018>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com