mirror of
https://github.com/python/cpython.git
synced 2025-08-25 11:15:02 +00:00
SF bug #759889: Pickling of Random is broken
* Implement __reduce__() to support pickling. * Add a test case to prove a successful roundtrip through pickle.
This commit is contained in:
parent
663219a8cc
commit
5f078ff7f0
2 changed files with 10 additions and 0 deletions
|
@ -123,6 +123,9 @@ class Random(_random.Random):
|
|||
def __setstate__(self, state): # for pickle
|
||||
self.setstate(state)
|
||||
|
||||
def __reduce__(self):
|
||||
return self.__class__, (), self.getstate()
|
||||
|
||||
## -------------------- integer methods -------------------
|
||||
|
||||
def randrange(self, start, stop=None, step=1, int=int, default=None):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue