Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:

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

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32554>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to