classification
Title: random.seed() doesn't work with bytes and version=1
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Mariatta Nosy List: Mariatta, rhettinger, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2017-09-15 12:10 by serhiy.storchaka, last changed 2017-09-20 18:04 by Mariatta. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 3614 merged rhettinger, 2017-09-16 09:02
PR 3629 closed python-dev, 2017-09-17 16:04
PR 3659 merged python-dev, 2017-09-19 16:29
Messages (12)
msg302246 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-09-15 12:10
The behavior of random.seed() with bytes and version=1 is specially documented. But actually it doesn't work.

>>> import random
>>> random.seed(b'abc', version=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/serhiy/py/cpython/Lib/random.py", line 113, in seed
    x = ord(a[0]) << 7 if a else 0
TypeError: ord() expected string of length 1, but int found
msg302370 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2017-09-17 16:04
New changeset 132a7d7cdbc7cb89fa1c1f4e8192241c3d68f549 by Raymond Hettinger in branch 'master':
bpo-31482:  Missing bytes support for random.seed() version 1 (#3614)
https://github.com/python/cpython/commit/132a7d7cdbc7cb89fa1c1f4e8192241c3d68f549
msg302512 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-09-19 10:06
Raymond, why the fix is not backported to 3.6?
msg302535 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2017-09-19 15:58
Mariatta, what is the procedure for completing the backport?  I can see the miss-islington bot made a commit but it didn't take in the 3.6 branch.
msg302538 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-09-19 16:19
What is wrong with PR 3629?
msg302540 - (view) Author: Mariatta Wijaya (Mariatta) * (Python committer) Date: 2017-09-19 16:29
Hi Raymond, 

Somehow the backport PR https://github.com/python/cpython/pull/3629 was closed before instead of merged.

To retrigger the backport, we can re-apply the "needs backport to 3.6" label on the original PR (3614). I will do this now :)
msg302542 - (view) Author: Mariatta Wijaya (Mariatta) * (Python committer) Date: 2017-09-19 16:30
Backport PR has been created. Once the CI checks are done, we can squash and merge it.
msg302544 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-09-19 16:37
If PR 3629 was closed by mistake it could be just reopened, isn't?
msg302547 - (view) Author: Mariatta Wijaya (Mariatta) * (Python committer) Date: 2017-09-19 16:52
Serhiy, it can't be re-opened since miss-islington deleted the branch already.
msg302549 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-09-19 17:42
Ah, now I understand what happened. Thanks Mariatta.
msg302552 - (view) Author: Mariatta Wijaya (Mariatta) * (Python committer) Date: 2017-09-19 17:56
New changeset c6ce8fba07ea6798eac46ab2808167afecd4d90b by Mariatta (Miss Islington (bot)) in branch '3.6':
[3.6] bpo-31482:  Missing bytes support for random.seed() version 1 (GH-3614) (GH-3659)
https://github.com/python/cpython/commit/c6ce8fba07ea6798eac46ab2808167afecd4d90b
msg302647 - (view) Author: Mariatta Wijaya (Mariatta) * (Python committer) Date: 2017-09-20 18:04
Backport was done. Thanks.
History
Date User Action Args
2017-09-20 18:04:36Mariattasetstatus: open -> closed

messages: + msg302647
stage: patch review -> resolved
2017-09-19 17:56:36Mariattasetmessages: + msg302552
2017-09-19 17:42:18serhiy.storchakasetmessages: + msg302549
2017-09-19 16:52:56Mariattasetmessages: + msg302547
2017-09-19 16:37:16serhiy.storchakasetmessages: + msg302544
2017-09-19 16:30:49Mariattasetmessages: + msg302542
2017-09-19 16:29:52python-devsetstage: resolved -> patch review
pull_requests: + pull_request3648
2017-09-19 16:29:11Mariattasetmessages: + msg302540
2017-09-19 16:19:08serhiy.storchakasetmessages: + msg302538
2017-09-19 15:58:52rhettingersetassignee: rhettinger -> Mariatta

messages: + msg302535
nosy: + Mariatta
2017-09-19 10:06:12serhiy.storchakasetstatus: closed -> open

messages: + msg302512
2017-09-17 16:06:45rhettingersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2017-09-17 16:04:43python-devsetpull_requests: + pull_request3618
2017-09-17 16:04:32rhettingersetmessages: + msg302370
2017-09-16 09:02:38rhettingersetkeywords: + patch
stage: patch review
pull_requests: + pull_request3605
2017-09-15 12:10:39serhiy.storchakacreate