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: random.SystemRandom(seed) documentation issue
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.7, Python 3.6, Python 3.3, Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: gem, rhettinger
Priority: low Keywords:

Created on 2017-01-04 23:44 by gem, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (8)
msg284678 - (view) Author: Gary E. Miller (gem) Date: 2017-01-04 23:44
The man page for random.SystemRandom([seed]]) fails to mention that the parameter 'seed' is never used.  This should be prominent in the documentation.  I have found several cases where a seed was provided to SystemRandom().

https://docs.python.org/2.7/library/random.html?highlight=systemrandom

Present in all versions of Python docs that I could find.
msg284680 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2017-01-05 00:15
From the docs at https://docs.python.org/3/library/random.html#alternative-generator :

"""
class random.SystemRandom([seed])
Class that uses the os.urandom() function for generating random numbers from sources provided by the operating system. Not available on all systems. Does not rely on software state, and sequences are not reproducible. Accordingly, the seed() method has no effect and is ignored. The getstate() and setstate() methods raise NotImplementedError if called.
"""

What is it that you think needs to be added or changed?
msg284681 - (view) Author: Gary E. Miller (gem) Date: 2017-01-05 00:53
I would change:

"Accordingly, the seed() method has no effect and is ignored."

To:

"Accordingly, the optional seed parameter and the seed() method have no effect and are ignored."

It was not obvious to me that the seed paramrter got passed to the seed() method and was then ignored.  After all, why have an ignored parameter that is not plainly documented as ignored.
msg284683 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2017-01-05 01:18
> why have an ignored parameter that is not plainly documented as ignored.

Because it improves the substitutability of one RNG for another (i.e. the same reason that we even have a seed() method).
msg284686 - (view) Author: Gary E. Miller (gem) Date: 2017-01-05 01:43
> > why have an ignored parameter that is not plainly documented as ignored.

> Because it improves the substitutability of one RNG for another (i.e. the same reason that we even have a seed() method).

I understand why it the parameter it there.  I think the parameter should stay there.  I am all for orthogonal functions.  It just needs to be documented that the parameter is ignored by SystemRandom().

Programmers are being misled by the online documentation and adding a seed parameter when it does nothing.

I should not have to read the library code to find out that a parameter is ignored.
msg284688 - (view) Author: Gary E. Miller (gem) Date: 2017-01-05 01:45
Is there a better place to submit documentation problems to?  After my programming team spends a lot of valuable time figuring what the Python doc failed to mention I would like this knowledge to be put to good use by others.  Paying it forward if you will.
msg284690 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2017-01-05 02:00
Thank you for the submission.  I respect what you're trying to do, but disagree that there is any issue here.   The docs are clear that System Random uses os.urandom() for creating random numbers, that there is not state, that sequences aren't reproducible, and that seed method has no effect and is ignored.  Also, the square brackets on the seed argument is our traditional way of saying that an argument is optional.

Apologies, but I'm going to close this.  IMO, the proposed wording is less clear and doesn't really help if someone is already misunderstanding what SystemRandom is all about and is imagining that the "seed" argument has some effect when the seed method is documented as being ignored.
msg284693 - (view) Author: Gary E. Miller (gem) Date: 2017-01-05 02:43
> The docs are clear that System Random uses os.urandom() for creating random numbers, that there is not state, that sequences aren't reproducible, and that seed method has no effect and is ignored.  

Agreed, but not relevant. I have anecdotal proof that the docs are not clear to a number of talented Python programmers that the seed parameter is not used.  Or that the seed parameter is passed to the seed() method (and thus unused).

Disappointing...
History
Date User Action Args
2022-04-11 14:58:41adminsetgithub: 73347
2017-01-05 02:43:15gemsetmessages: + msg284693
2017-01-05 02:00:55rhettingersetstatus: open -> closed

messages: + msg284690
2017-01-05 01:45:43gemsetmessages: + msg284688
2017-01-05 01:43:53gemsetmessages: + msg284686
2017-01-05 01:18:31rhettingersetpriority: normal -> low
resolution: not a bug
messages: + msg284683
2017-01-05 00:53:40gemsetmessages: + msg284681
2017-01-05 00:15:46rhettingersetmessages: + msg284680
2017-01-05 00:13:35rhettingersetassignee: rhettinger

nosy: + rhettinger
2017-01-04 23:44:44gemcreate