This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: DeprecationWarning in test_random due to invalid seed arguments
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: xtreak Nosy List: pablogsal, rhettinger, serhiy.storchaka, vstinner, xtreak
Priority: normal Keywords: patch

Created on 2019-09-11 16:06 by xtreak, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 15987 merged xtreak, 2019-09-11 16:10
Messages (6)
msg351966 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-09-11 16:06
Since d0cdeaab76fef8a6e5a04665df226b6659111e4e (bpo-32554) using random.seed raises DeprecationWarning for some types. This is not handled in test_random causing DeprecationWarnings. I will raise a PR for this.

commit d0cdeaab76fef8a6e5a04665df226b6659111e4e
Author: Raymond Hettinger <rhettinger@users.noreply.github.com>
Date:   Thu Aug 22 09:19:36 2019 -0700

    bpo-32554: Deprecate hashing arbitrary types in random.seed() (GH-15382)
msg352014 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-09-11 18:55
Thanks for doing this.

If you don't mind, let's hold off one day so I can take a closer look at this when I get home tonight.
msg352021 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-09-11 20:05
Sure, I think these were not caught since deprecation warnings are not shown as part of CI as failure. I just caught them at the sprint running with -Wall.
msg352027 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-09-11 22:35
I confirm that test_random currently fails using -Werror:

$ ./python -W error -m test  -v test_random

======================================================================
ERROR: test_seed_when_randomness_source_not_found (test.test_random.MersenneTwister_TestBasicOps)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/vstinner/python/master/Lib/unittest/mock.py", line 1319, in patched
    return func(*newargs, **newkeywargs)
  File "/home/vstinner/python/master/Lib/test/test_random.py", line 60, in test_seed_when_randomness_source_not_found
    self.test_seedargs()
  File "/home/vstinner/python/master/Lib/test/test_random.py", line 46, in test_seedargs
    self.gen.seed(arg)
  File "/home/vstinner/python/master/Lib/random.py", line 156, in seed
    _warn('Seeding based on hashing is deprecated\n'
DeprecationWarning: Seeding based on hashing is deprecated
since Python 3.9 and will be removed in a subsequent version. The only 
supported seed types are: None, int, float, str, bytes, and bytearray.

======================================================================
ERROR: test_seedargs (test.test_random.MersenneTwister_TestBasicOps)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/vstinner/python/master/Lib/test/test_random.py", line 46, in test_seedargs
    self.gen.seed(arg)
  File "/home/vstinner/python/master/Lib/random.py", line 156, in seed
    _warn('Seeding based on hashing is deprecated\n'
DeprecationWarning: Seeding based on hashing is deprecated
since Python 3.9 and will be removed in a subsequent version. The only 
supported seed types are: None, int, float, str, bytes, and bytearray.


I also confirm that PR 15987 fix the issue.
msg352043 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-09-12 03:14
Okay.  This looks good to go.

I don't remember why the original test repeated some of the seeds -- that would normally only be done if caching was present.
msg352056 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-09-12 08:13
New changeset a06d683d7fd88721eaf59abcf5b02eb82045c7b1 by Serhiy Storchaka (Xtreak) in branch 'master':
bpo-38120: Fix DeprecationWarning in test_random for invalid type of arguments to random.seed. (GH-15987)
https://github.com/python/cpython/commit/a06d683d7fd88721eaf59abcf5b02eb82045c7b1
History
Date User Action Args
2022-04-11 14:59:20adminsetgithub: 82301
2019-09-12 08:13:56serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-09-12 08:13:25serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg352056
2019-09-12 03:14:33rhettingersetassignee: rhettinger -> xtreak
messages: + msg352043
2019-09-11 22:35:11vstinnersetmessages: + msg352027
2019-09-11 20:05:01xtreaksetmessages: + msg352021
2019-09-11 18:55:02rhettingersetassignee: rhettinger
messages: + msg352014
2019-09-11 16:10:11xtreaksetkeywords: + patch
stage: patch review
pull_requests: + pull_request15616
2019-09-11 16:06:47xtreakcreate