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.

Author rhettinger
Recipients docs@python, johnnyd, mark.dickinson, rhettinger, serhiy.storchaka, vstinner
Date 2018-06-24.19:44:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1529869495.86.0.56676864532.issue32554@psf.upfronthosting.co.za>
In-reply-to
Content
I'm thinking of something like this:

$ git diff
diff --git a/Lib/random.py b/Lib/random.py
index 1e0dcc87ed..f479e66ada 100644
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -136,12 +136,17 @@ class Random(_random.Random):
             x ^= len(a)
             a = -2 if x == -1 else x

-        if version == 2 and isinstance(a, (str, bytes, bytearray)):
+        elif version == 2 and isinstance(a, (str, bytes, bytearray)):
             if isinstance(a, str):
                 a = a.encode()
             a += _sha512(a).digest()
             a = int.from_bytes(a, 'big')

+        elif not isinstance(a, (type(None), int, float, str, bytes, bytearray)):
+            _warn('Seeding based on hashing is deprecated.\n'
+                  'The only supported seed types are None, int, float, '
+                  'str, bytes, and bytearray.', DeprecationWarning, 2)
+
         super().seed(a)
         self.gauss_next = None
History
Date User Action Args
2018-06-24 19:44:55rhettingersetrecipients: + rhettinger, mark.dickinson, vstinner, docs@python, serhiy.storchaka, johnnyd
2018-06-24 19:44:55rhettingersetmessageid: <1529869495.86.0.56676864532.issue32554@psf.upfronthosting.co.za>
2018-06-24 19:44:55rhettingerlinkissue32554 messages
2018-06-24 19:44:55rhettingercreate