From 5f078ff7f0c6bb5086fae077379fc79729c34d2d Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Tue, 24 Jun 2003 20:29:04 +0000 Subject: SF bug #759889: Pickling of Random is broken * Implement __reduce__() to support pickling. * Add a test case to prove a successful roundtrip through pickle. --- Lib/random.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Lib/random.py') diff --git a/Lib/random.py b/Lib/random.py index 1ae25532d3f..1a0b8f341e4 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): -- cgit v1.2.3