@@ -121,7 +121,10 @@ def __init_subclass__(cls, /, **kwargs):
121121 break
122122
123123 def seed (self , a = None , version = 2 ):
124- """Initialize internal state from hashable object.
124+ """Initialize internal state from a seed.
125+
126+ The only supported seed types are None, int, float,
127+ str, bytes, and bytearray.
125128
126129 None or no argument seeds from current time or from an operating
127130 system specific randomness source if available.
@@ -143,12 +146,20 @@ def seed(self, a=None, version=2):
143146 x ^= len (a )
144147 a = - 2 if x == - 1 else x
145148
146- if version == 2 and isinstance (a , (str , bytes , bytearray )):
149+ elif version == 2 and isinstance (a , (str , bytes , bytearray )):
147150 if isinstance (a , str ):
148151 a = a .encode ()
149152 a += _sha512 (a ).digest ()
150153 a = int .from_bytes (a , 'big' )
151154
155+ elif not isinstance (a , (type (None ), int , float , str , bytes , bytearray )):
156+ _warn ('Seeding based on hashing is deprecated\n '
157+ 'since Python 3.9 and will be removed in a subsequent '
158+ 'version. The only \n '
159+ 'supported seed types are: None, '
160+ 'int, float, str, bytes, and bytearray.' ,
161+ DeprecationWarning , 2 )
162+
152163 super ().seed (a )
153164 self .gauss_next = None
154165
0 commit comments