summaryrefslogtreecommitdiffstats
path: root/Lib/random.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2003-06-24 20:29:04 (GMT)
committerRaymond Hettinger <python@rcn.com>2003-06-24 20:29:04 (GMT)
commit5f078ff7f0c6bb5086fae077379fc79729c34d2d (patch)
tree77471542e4966c70b2076b500f53014f3afc6d5d /Lib/random.py
parent663219a8cc0501791c45aa18986770c38c6430da (diff)
downloadcpython-5f078ff7f0c6bb5086fae077379fc79729c34d2d.zip
cpython-5f078ff7f0c6bb5086fae077379fc79729c34d2d.tar.gz
cpython-5f078ff7f0c6bb5086fae077379fc79729c34d2d.tar.bz2
SF bug #759889: Pickling of Random is broken
* Implement __reduce__() to support pickling. * Add a test case to prove a successful roundtrip through pickle.
Diffstat (limited to 'Lib/random.py')
-rw-r--r--Lib/random.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/random.py b/Lib/random.py
index 1ae2553..1a0b8f3 100644
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -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):